I have a column in my database named Created which is a datetime and a column named M开发者_如何学Cinutes which is a varchar(5) and will contains values such as 0, 60, 120, etc.
How can I write a LINQ statment that only returns those records:
where Created + Minutes has gone passed the current time?
Thank you!
--- Update: code so far ---
var results = from emails in MyDAL.Context.Emails
emails.Created.Value.AddMinutes(double.Parse(emails.Minutes)) > DateTime.Now
select emails;
For others looking for the answer, here is how I ended up making it work....
System.Data.Objects.EntityFunctions.AddMinutes(emails.Created, emails.Minutes) < DateTime.Now
Well you could try:
DateTime now = DateTime.UtcNow;
var query = from record in db.Records
where record.Create.AddMinutes(int.Parse(record.Minutes)) > now
select record;
Whether that will work or not depends on the LINQ provider...
精彩评论