0

My linq query now,

 return _db.Details
           .FirstOrDefault(c => c.Master.Id.Value == nId && 
                                c.Id == c.Master.Id && 
                                c.Alert.Va <= c.Va && 
                                DateTimeNowc.ValidityTill <= (EntityFunctions.AddHours(DateTime.UtcNow,5) &&
                                EntityFunctions.AddMinutes(DateTime.UtcNow,30)));

ERROR:

DateTime? EntityFunctions.Addminutes(DateTime?timevalue, int? addvalue) (+2 overload(s))

Invokes the canonical Add Minutes function. For Information about the canonical AddMinutes function, see Date and Time canonical Functions(Entity SQL).

Here I get line errorenter image description here

Duk
  • 905
  • 5
  • 15
  • 34

2 Answers2

1
DateTimeNowc.ValidityTill <= (EntityFunctions.AddHours(DateTime.UtcNow, 5) &&
EntityFunctions.AddMinutes(DateTime.UtcNow, 30)));

You're trying to perform && on two DateTime instances. That's not gonna work.

You should place one method call within another:

EntityFunctions.AddMinutes(EntityFunctions.AddHours(DateTime.UtcNow, 5), 30));
MarcinJuraszek
  • 124,003
  • 15
  • 196
  • 263
0

Your comparison syntax is wrong. If you try to compare if the time is <= 5hours 30 minutes, try to use just AddMinutes().

//5*60 minutes + 30 minutes
DateTimeNowc.ValidityTill <= EntityFunctions.AddMinutes(DateTime.UtcNow,330)));
Marco
  • 22,856
  • 9
  • 75
  • 124