我的数据库表中有两列(dueDate& lateMinutes)。
如何创建Where lateate,将lateMinutes添加到dueDate并将结果与给定日期(aGivenDate)进行比较。
例如。 .where(dueDate + lateMinutes> aGivenDate)
知道如何使用Breeze查询谓词吗?
任何帮助表示感谢。
此致
保罗。
答案 0 :(得分:2)
在微风中没有支持日期算术的标准查询语法,因此最好的办法是使用带参数的命名查询。即假设您的EntityType的名称是' Schedule'像这样的东西
在客户端
var q = EntityQuery.from("SchedulesAfter")
.where(...) // this can be any valid where clause for the 'Schedule' type ( or can be omitted completely if you don't need additional query restrictions.
.withParameter( { givenDate: aGivenDate });
在服务器上
[HttpGet]
public IQueryable<Schedule> SchedulesAfter(DateTime givenDate) {
// This needs to return a valid IQueryable
// You will need to find the correct EF syntax to support your query here. You may need to use an EF function here instead.
return ContextProvider.Context.Schedules
.Where(s => DbFunctions.AddMinutes(s.DueDate ,s.LateMinutes) > givenDate);
}
实际上,您使用参数在服务器上调用自定义查询方法,然后告诉服务器如何使用此参数实现查询。