Wednesday, December 28, 2016

The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.

As the ERROR says:

The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.

Error:
  

var CustomersLst = (from a in entities.Customers
    .Where(x => x.FirstName.Contains("VARA") &&
    x.LastName.Contains("REDDY") &&    
    x.JoiningDate.Date >= JDate.Date)    
    select
    {
     FirstName = a.FirstName,
     LastName = a.LastName,
     CreatedDate = a.CreatedDate
    });

Solution:

  

var CustomersLst = (from a in entities.Customers
    .Where(x => x.FirstName.Contains("VARA") &&
    x.LastName.Contains("REDDY") &&    
    EntityFunctions.TruncateTime(x.JoiningDate.Date) >= JDate.Date)    
    select
    {
     FirstName = a.FirstName,
     LastName = a.LastName,
     CreatedDate = a.CreatedDate
    });



No comments:

Post a Comment