Which functions does EF 4.0 support?
Sometimes I get an exception like this:
This method cannot be translated into a store expre开发者_Python百科ssion.
Is there any list what EF 4.0 supports and what doesn't?
I have just googled, but nothing ;(.
The following lists the LINQ methods which are supported.
LINQ To Entities also provides the following Canonical Function Mapping for CLR type operations to SQL functions. These are the methods that should be supported, by default, by all providers. For example, String.Contains should always map to a LIKE statement in SQL, or an IndexOf statement.
However, be aware that different providers are free to do their own mapping. I have seen some EF providers which do not support the full "canonical" list of functions, or add their own. Since each EF provider does the mapping themselves, it's impossible to give a definitive answer, other than the standard listed above.
Supported and Unsupported LINQ Methods (LINQ to Entities)
http://msdn.microsoft.com/en-us/library/bb738550.aspx
By design, LINQ to Entities requires the whole LINQ query expression to be translated to a server query. Only a few uncorrelated subexpressions (expressions in the query that do not depend on the results from the server) are evaluated on the client before the query is translated. Arbitrary method invocations that do not have a known translation are NOT supported. To be more specific, LINQ to Entities only support Parameterless constructors and Initializers. Please take a look at LINQ to Entities, what is not supported? for more info.
精彩评论