I have this code:
from pr in e.ProgramSetup.Include("Program").Include("Program.Client")
where pr.DateBegin < DateTime.Now
&& pr.DateEnd > DateTime.Now.AddDays(pr.DateEndOffset)
select pr).ToList();
It does not work, because AddDays() is not possible to use for generating sql.
So is there some another way? Now i select everything and filter it finaly by foreach, but it is not good way in my opinion.
Problem is that pr.DateEndOffset is also only in db, it is not constant...
AddDays() method in C# is used to add the specified number of days to the value of this instance. This method returns a new DateTime.
Firstly, get the current date. Now, use AddDays() method to add days to the current date. Here, we are adding 10 days to the current date.
You can use the DateTime. Add() method to add the time to the date. DateTime date = DateTime. Now; TimeSpan time = new TimeSpan(36, 0, 0, 0); DateTime combined = date.
using System.Data.Entity;
...
DbFunctions.AddDays(dateFromDataStore, numDaysToAdd);
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