Monday, March 08, 2010

Unable to create a constant value of type 'Closure type'


When working with the Entity Framework I got the following error when I was doing a filter

Unable to create a constant value of type 'Closure type'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.

and all I was only doing was a normal Where query with a cast to an int as follows

_entities.Persons.Where(it => it.EmployeeID == (int)EmployeeType.Permanent).ToList();

I decided to move the int cast to a temp variable outside the Where query as the error said that only primitive types were supported and it seemed to work

Labels:

0 Comments:

Post a Comment

<< Home