I am working on an application in MVC4 and Entity Framework 5 and have recently encountered this exception when executing my request.
{"LINQ to Entities does not recognize the" System.String PadLeft (Int32, Char) "method, and this method cannot be converted to a storage expression." }
When I came across similar errors in the past, I just made a variable outside the query and then used the variable in the LINQ statement. Unfortunately, in this case I am manipulating the results of the string, so I'm not sure how to do this, or if this is the best method. Any help would be greatly appreciated. My request is below:
IQueryable<System.String> LEAPrograms = db.Datamart_Draft
.Where(where => where.snapshot_id == snapshot_id
&& !String.IsNullOrEmpty(where.entity_program))
.Select(sel => (sel.entity_program.PadLeft(PROGRAMLENGTH, '0'))).Distinct();
source
share