我有我的SQL表名爲「CreatedDate」一個DateTime類型列,和我通過使用「DateTime.Now」從我的asp.net應用程序通過此列的值....日期比較使用LINQ
在我CreatedDate列中的數據都是,
CreatedDate
-----------
2012-05-07 18:56:17.487
2012-05-07 18:56:28.443
2012-05-07 19:21:24.497
2012-05-14 15:22:04.587
我需要這個CreatedDate
得到DATAS。
我試着像
DataAccess.Entities dataEntities = new DataAccess.Entities();
DataAccess.Employee employee = dataEntities.Employees
.First(e => e.CreatedDate == DateTime.Today);
像這樣的情況,我有數據,這個日期(2012-05-14),但mininutes部分differes (the DateTime.Today gives '2012-05-14 12:00:000' like this)
在這裏,它表明類似的錯誤,序列不包含任何元素....
我怎樣才能比較「日期」單獨Linq中.....任何人都可以幫助我在這裏,,,
非常感謝Shyju,你救了我時間,我一直在嘗試超過1小時....感謝alottttttttt – shanish
@Shanish:很高興它幫助了你。 – Shyju
但是它的錯誤例如「指定的類型成員Date」在LINQ to Entities中不被支持,只支持初始值設定項,實體成員和實體導航屬性。 – shanish