There are times when you want to perform query on only date part of the column that has type DateTime in database. Entity framework does not support DateTime.Date property but provides a helper class EntityFunctions . EntityFunctions has a method TruncateTime that can be called in Linq2Entities query and truncates the time part from datetime. Here is how to use it using (AccountEntities dal = new AccountEntities ()) { DateTime dtStart=DateTime.Now.AddDays(-20).Date; DateTime dtEnd=DateTime.Now.Date; transactions = (from t in dal.Transactions where EntityFunctions.TruncateTime (t.TransactionDate.Value) ...
I document random stuff on this Blog. It can be a piece of code , my personal experience, a fun fact or anything else.