メンバーテーブルのBirthdateという名前のnull可能なDateTimeフィールドがあります。私は次のn日に誕生日のあるメンバーを取得する必要があります。私はいくつかの方法を試しましたが、どれも働いていませんでした。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
);
のDateTimeコンストラクタ
GetAll().OrderByDescending(m => m.CreateDate)
.Where(x => x.BirthDate.HasValue
&& (endDate - x.BirthDate.Value).Days <= n)
にx.BirthDateを渡すことはできません認識エラーをスロー。
これを行うにはどの作業方法も簡単ですか?
フィルタリングを開始する前に 'GetAll()'が返すものをまず調べてみましたか? – yoger