The thing about it is that LINQ queries are transformed by the compiler into an expression tree. This expression tree is then converted into T-SQL and passed to the server. LINQ to SQL maps certain methods like String.
Contains to the T-SQL equivalents In the first example, LINQ apparently does not map Convert. ToInt32 to anything and the exception is thrown. The reason it works in your second example is because the Convert.
ToInt32 call is done outside of the query so it isn't part of the expression tree and doesn't need to be converted to T-SQL This MSDN page describes how LINQ to SQL translates various data types, operators, and methods into T-SQL. (Although the documentation does suggest Convert. ToInt32 is supported so I'm not sure what else might be going on here.) Sorry just realized this is ADO.
NET Entity Framework, not LINQ to SQL This page lists the ADO. NET Entity Framework mappings.It is a bit more restrictive, mostly because it needs to work with multiple providers.
The thing about it is that LINQ queries are transformed by the compiler into an expression tree. This expression tree is then converted into T-SQL and passed to the server. LINQ to SQL maps certain methods like String.
Contains to the T-SQL equivalents. In the first example, LINQ apparently does not map Convert. ToInt32 to anything and the exception is thrown.
The reason it works in your second example is because the Convert. ToInt32 call is done outside of the query so it isn't part of the expression tree and doesn't need to be converted to T-SQL. This MSDN page describes how LINQ to SQL translates various data types, operators, and methods into T-SQL.(Although the documentation does suggest Convert.
ToInt32 is supported so I'm not sure what else might be going on here. ) Sorry just realized this is ADO. NET Entity Framework, not LINQ to SQL.
This page lists the ADO. NET Entity Framework mappings. It is a bit more restrictive, mostly because it needs to work with multiple providers.
1 clear explanation – Luiscencio Mar 17 '10 at 23:15 No, but if you create a user-defined function in SQL and add that to your data context, you can use them in your queries. – Josh Einstein Mar 17 '10 at 23:16 so if I am using mysql and add some stored procedure to my DB I can call it somehow? – Luiscencio Mar 17 '10 at 23:17 I apologize I just realized I linked to LINQ to SQL documentation, not ADO.
NET Entity Framework which has some more restrictions due to the fact that it needs to support several different providers. I am honestly not sure how EF supports MySQL stored procedures or functions. – Josh Einstein Mar 17 '10 at 23:19 but basically your answer is why... isn't it?
– Luiscencio Mar 17 '10 at 23:21.
Because your LINQ to Ent. Doesn't compile the query into MSIL with all the meta data, but simply translates the query into a few extantion methods and is bounded to lambda parsing abuilities of the languge. That means that this code: var results = from c in SomeCollection where c.
SomeProperty c. SomeProperty new {c. SomeProperty, c.
OtherProperty}).
The thing about it is that LINQ queries are transformed by the compiler into an expression tree. This expression tree is then converted into T-SQL and passed to the server. LINQ to SQL maps certain methods like String.
Contains to the T-SQL equivalents. In the first example, LINQ apparently does not map Convert. ToInt32 to anything and the exception is thrown.
The reason it works in your second example is because the Convert.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.