Reputation: 2305
I need to do this :
context.Ads.Where(c => c.PublishedDate.HasValue &&
c.EndDate.HasValue &&
c.EndDate.Value.AddTicks(c.PublishedDate.Value.Ticks) > currentTime &&
c.AdStatusMail.Where(b => b.StatusKey != (int)AdStatusMailKey.EndedRemainder && b.StatusKey != (int)AdStatusMailKey.MiddleRemainder).Count() < 1)
.ToList();
The problem is that AddTicks can´t be used in Linq. I have looked at the EntityFunctions but can´t see how to use it to do what I need?
Upvotes: 1
Views: 235
Reputation: 31721
IQueryable can't handle the ticks, make it IEnumerable (or tolist). Here is an example:
context.Ads.Where(c => c.PublishedDate.HasValue && c.EndDate.HasValue && c.AdStatusMail.Where(b => b.StatusKey != (int)AdStatusMailKey.EndedRemainder && b.StatusKey != (int)AdStatusMailKey.MiddleRemainder).Count() < 1)
.AsEnumerable()
.Where (c => c.EndDate.Value.AddTicks(c.PublishedDate.Value.Ticks) > currentTime)
.ToList();
Upvotes: 1