LINQ to Entities does not recognize the method ToString()
Posted: Thu 22 Mar 2012 18:46
I am getting the following error.
$exception {"LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression."} System.Exception {System.NotSupportedException}
The Look at the commented lines below. If I uncomment them then I get the error:
Note that LinqConnect is declaring both date fields as System.DateTime?
(nullable) so I have to convert them to strings for my WCF connection.
$exception {"LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression."} System.Exception {System.NotSupportedException}
The Look at the commented lines below. If I uncomment them then I get the error:
Code: Select all
GPLModel.GPLEntities context = new GPLModel.GPLEntities();
var matches = context.Viewbostons.Select(item => new CatalogEntry
{
idx = item.Idx,
product = item.Product,
size = (long)item.SizeBytes,
//date = item.Date.ToString(),
type = item.Type,
classification = item.Classification,
distributor = item.Distributor,
//egplDate = item.EgplDate.ToString(),
classificationVal = (int)item.ClassificationInt,
handling = item.Handling,
creator = item.Creator,
datum = item.Datum,
elevation = (int)item.ElevationFt,
description = item.Description,
dirLocation = item.DoLocation,
bbox = item.Bbox,
uniqID = item.UniqId
});
CatalogEntry[] results = matches.ToArray();
(nullable) so I have to convert them to strings for my WCF connection.