|| Published on :
Sunday, April 26, 2015 || Views:
SqlClient.SqlFunctions.DateDiff in LINQ LINQ Examples SqlClient.SqlFunctions.DateDiff
In some situation, we have to filter or delete or get records whose creation times comes under particular time like 1 hour or two hour. In below example I will going to demostrate how to use SqlClient.SqlFunctions.DateDiff in Entity Framework to delete some records which are older than 2 hours.
public DB DeleteOldRecords(DEMOEntities objEntities)
Result = DB.Unknown;
(from p in objEntities.tblDEMO.Where(x => System.Data.Objects.SqlClient.SqlFunctions.DateDiff("hour", x.Timestamp, DateTime.Now) >= 2) select p).ToList().ForEach(objEntities.DeleteObject);
catch (Exception ex)
So, In this tutorial, you have learn, How to make use SqlClient.SqlFunctions.DateDiff in LINQ with example.
Stay Tunned for more articles like this.