2014-11-11 9 views
0

데이터베이스 테이블에 두 개의 열 (dueDate & lateMinutes)이 있습니다.Breeze를 사용하여 계산 된 열을 쿼리하는 방법

dueDate에 lateMinutes를 추가하고 주어진 날짜 (aGivenDate)와 결과를 비교하는 Where 술어는 어떻게 작성합니까?

예 : .where (dueDate + lateMinutes> aGivenDate)

술어가있는 Breeze 쿼리에서 어떻게해야할까요?

도움을 주시면 감사하겠습니다.

감사합니다,

폴.

답변

2

breeze 내에 날짜 계산을 지원하는 표준 쿼리 구문이 없으므로 매개 변수와 함께 명명 된 쿼리를 사용하는 것이 가장 좋습니다. 서버 사실상

[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); 
} 

에 클라이언트

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 }); 
  • 에이

    • 같은 즉, 그래서 EntityType의 이름을 말하는 것을 가정 '일정'뭔가 , 매개 변수를 사용하여 서버에서 사용자 지정 쿼리 메서드를 호출 한 다음 쿼리 u를 구현하는 방법을 서버에 알리는 중입니다 이 매개 변수를 부르십시오.

  • +0

    좋은 답변입니다. 감사합니다. – user3571051

    +1

    @Jay Traband 제 생각에'Where (s => s.DueDate + s.LateMinutes> givenDate)'는'Where (s => DbFunctions.AddMinutes (s.DueDate, s.LateMinutes)> givenDate로 대체되어야합니다) 'LastMinutes가'int'라고 가정합니다. –

    +0

    감사합니다. :) 업데이트되었습니다. –

    관련 문제