0
在波紋管LINQ查詢,我發現了以下異常:尋址指定的類型成員日期在LINQ是不支持的實體除外
指定類型的成員「日期」在LINQ是不支持的實體。 僅支持初始值設定項,實體成員和實體導航屬性 。
查詢:
var query = db.Cases
.Where(
dateInterval.Equals(ControlValues.Today)? DbFunctions.TruncateTime(c.EffectiveDate.Date).Value.Day == currentDayNum :
dateInterval.Equals(ControlValues.CurrentWeek) ? CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(
DbFunctions.TruncateTime(c.EffectiveDate.Date).Value, CalendarWeekRule.FirstFourDayWeek,DayOfWeek.Monday) == currentWeekNum :
dateInterval.Equals(ControlValues.NextWeek) ? CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(
DbFunctions.AddDays(DbFunctions.TruncateTime(c.EffectiveDate.Date), 7).Value, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday) == nextWeekNum :
dateInterval.Equals(ControlValues.CurrentMonth) ? DbFunctions.TruncateTime(c.EffectiveDate.Date).Value.Month == currentMonthNum : true)
正如你可以從代碼中看到我已經使用DbFunctions.TruncateTime功能查詢,neverthe少異常仍跳躍。任何幫助,將不勝感激
謝謝布魯斯,這是這裏的問題。現在,我得到了同樣的查詢不同的問題,我已經打開了一個新的問題,請查看:http://stackoverflow.com/questions/22487641/extracting-week-number-from-datetime-value-in-linq -to-實體查詢 –