操作该法典:
public bool CheckTime(DateTime date, int UserID, int TotalTimeMin)
{
using (var context = new myDB())
{
var assginments = from c in context.Assignments.Where(x=>(x.AssignmentDateTime < date && x.AssignmentDateTime.Value.AddMinutes(TotalTimeMin) > date) ||
(x.AssignmentDateTime < date.AddMinutes(TotalTimeMin))) select c;
if(assginments != null) return false;
else return true;
}
}
我发现这一错误。
LINQ to Entities does not recognize the method System.DateTime AddMinutes(Double) method, and this method cannot be translated into a store expression.
TotalTimeMin is int. I am not sure what cause this: AssignmentDateTime is DateTime? and maybe this is the problem ?