比較我有這樣的代碼實體框架和LINQ - 日期時間
public List<CalendarData> GetCalendarData(DateTime day)
{
List<CalendarData> list = new List<CalendarData>();
using (dataContext = new VTCEntities())
{
DateTime test = new DateTime(2010, 10, 20, 17, 45, 0);
var data = from z in dataContext.ReservationsSet
where z.start_time.Value == test
select z;
foreach (var r in data)
我希望做的是有這個
var data = from z in dataContext.ReservationsSet
where z.start_time.Value == day
select z;
我的問題是,z.start_time有時間部分也是。 DateTime日沒有記錄時間部分。有沒有辦法比較的日期部分沒有收到此錯誤
The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
當我做這個
var data = from z in dataContext.ReservationsSet
where z.start_time.Value.Date == test
select z;
喬恩,謝謝,如何翻轉簡單。我不知道爲什麼我比他們更難做事。你是男人。 – jim 2010-10-19 17:04:28