How do i use BETWEEN key word in Entity Framework?
This is my SQL query
SELECT *
FROM [HRM].[dbo].[meals]
WHERE SHIFTCODE = 'Normal'
AND 12.59 BETWEEN [STAR TIME] AND [STAR TIME]+DURATION/10;
This is my Entity Framework Code.
HRMEntities HRM = new HRMEntities();
meal ml = HRM.meals.SingleOrDefault(p => p.SHIFTCODE == "Normal");
value 12.59 can be a variable
You can use >=
and <=
with DateTime
to get a range.
HRMEntities HRM = new HRMEntities();
meal ml = HRM.meals.SingleOrDefault(p => p.SHIFTCODE == "Normal"
&& p.StartTime <= yourTime
&& (p.StartTime + duration) >= yourtime);
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