회원 테이블에 Birthdate라는 null 가능 DateTime 필드가 있습니다. 다음 며칠 동안 생일을 맞은 회원을 입회시켜야합니다. 나는 몇 가지 방법을 시도했지만 그들 중 누구도 일하지 않았습니다.NHibernate n 일 후 생일을 가진 회원을 얻는 방법
는DateTime startDate = DateTime.Now;
DateTime endDate = DateTime.Now.AddDays(n);
GetAll().Where(
x => x.BirthDate != null
&& new DateTime(startDate.Year, x.BirthDate.Value.Month, x.BirthDate.Value.Day, 1, 1, 1) >= startDate
&& new DateTime(endDate.Year, x.BirthDate.Value.Month, x.BirthDate.Value.Day, 1, 1, 1) <= endDate
);
1
2
GetAll().OrderByDescending(m => m.CreateDate)
.Where(x => x.BirthDate.HasValue
&& (endDate - x.BirthDate.Value).Days <= n)
는 인식 오류가 발생 날짜 시간 생성자 x.BirthDate을 통과 할 수 없다.
이 작업을 수행하는 간단한 방법을 알고 계십니까?
'GetAll()'이 (가) 필터링을 시작하기 전에 반환하는 것을 먼저 들여다 보셨습니까? – yoger