I want to write LINQ query from last 10 mins inserted records from table. How do I write it? Please help me.
Below is my SQL query:
SELECT AccountNumber, OrderID,RechargeDate
FROM OrderItem OI
WHERE RechargeStatus = 'SUCCESS'
AND AccountNumber ='" + AccountNumber + "' and DateADD(minute, -10,getdate() ) < RechargeDate AND OrderItemID <> " + OrderItemID + "";
Now, I want to rewrite the query above using LINQ.
You need to use Where
linq extension method.
db.OrderItems.Where(x => x.RechargeStatus.Equals("SUCCESS") &&
x.AccountNumber == strAccountNumber &&
x.RechargeDate > DateTime.Now.AddMinutes(-10) &&
x.OrderItemID != OrderItemID )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With