Tuesday, June 29, 2010

Linq

I am using Linq to entities in one of my project and here are the few things I found.

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

You may get the above error if you try to use the ToString() method in your Linq to SQL or lambda expression. To fix this try storing the ToString() value in a temporary variable and pass the temporary variable to the lambda query.

A specified Include path is not valid. The EntityType 'xxxxxxx' does not declare a navigation property with the name 'xxxxxxxx'

You may get the above error if you try to use a wrong entity name with Include.

eg. entities.Category.Include.Where(cat => cat.CategoryId == 1)

No comments:

Post a Comment