I'm unable to compile the below code and I'm getting the following error:
LINQ to Entities does not recognize the method 'System.String ToString()
I'm a bit surprised because I was able to do this in Linq2SQL but can't do it in Entity Framework.
Could I please get any help rewriting the below code ? I've seen a few examples related to this error but I couldn't find something that is specific to this scenario. Thanks
using (ctx)
{
var productResults = (from q in ctx.Products
where q.ProductId == productId && q.Model == productModel
select new Models.ProductDTO
{
Id = q.ProductId,
Name = q.Name.ToString(),
Year = q.Year.ToString("MMM ddd d HH:mm yyyy"),
Model = q.Model,
Description = q.Description.ToString()
}).Distinct().ToList().AsParallel();
Department.Products = productResults;
}