Joseph Michael Pesch
VP Programming

LINQ to Entities does not recognize the method 'System.String ToString(System.String)' method, and this method cannot be translated into a store expression.

by 27. December 2011 15:54

LINQ to Entities does not recognize the method 'System.String ToString(System.String)' method, and this method cannot be translated into a store expression.

One workaround for this is to convert the LINQ to Entities object to a LINQ to Objects object by adding .AsEnumerable() as in the sample below.

var qry = from itm in obj.Booksheets.AsEnumerable()
          where bks.Purchases.FirstOrDefault() == null
          select new
          {
            FormattedPrice = bks.WebPrice.ToString("#,###"),
          };

Tags:

LINQ | LINQ to Entities