Search code examples
entity-frameworkcasting

How cast Entity Framework Date into SQL Server Date with no time part


I have a date value like '2012/01/01 12:36:55' and I want to filter SQL Server date value from this like '2012/01/01'

I can convert('2012/01/01 12:36:55', date, 102) in SQL Server to get '2012/01/01' value.

The question is : how can I convert date 2012/01/01 12:36:55' in EF LINQ query to get '2012/01/01' value when my source object still is Queryable ?


Solution

  • I Use EntityFunctions Class in System.Data.Objects namespace, and it works very well

    public static class EntityFunctions
    

    http://msdn.microsoft.com/en-us/library/system.data.objects.entityfunctions.aspx

    http://msdn.microsoft.com/en-us/library/bb738626.aspx