LINQ to Entities joining on instance rather than id generates nasty SQL?

I can't say what is in the minds or the code of the ADO. NET team. That said, I see two possible issues: Possibly, the Id field in the underlying table in ContractAddresses or possibly just in the entity model, could not be defined as a primary key.

I somewhat doubt this is the problem, but it's worth double-checking The equals keyword may not have a good way actually to compare equality between the two objects in the join. In a quick web search, I did not find exactly what the equals uses for comparison, but this MSDN how-to leads me to believe that the Equals and GetHashCode methods are involved (even if composite keys are not involved). If you are just using the default object.

Equals inherited method, the Linq provider has to figure out the reference equality somehow, which I imagine could lead to some strange results I do like the solution by @Craig Stuntz in his comment, though. Also, you might want to get an execution plan for the longer query to see if it's really as bad as it looks; the query optimizer might do a better job than the code would indicate.

I can't say what is in the minds or the code of the ADO. NET team. That said, I see two possible issues: Possibly, the Id field in the underlying table in ContractAddresses, or possibly just in the entity model, could not be defined as a primary key.

I somewhat doubt this is the problem, but it's worth double-checking. The equals keyword may not have a good way actually to compare equality between the two objects in the join. In a quick web search, I did not find exactly what the equals uses for comparison, but this MSDN how-to leads me to believe that the Equals and GetHashCode methods are involved (even if composite keys are not involved).

If you are just using the default object. Equals inherited method, the Linq provider has to figure out the reference equality somehow, which I imagine could lead to some strange results. I do like the solution by @Craig Stuntz in his comment, though.

Also, you might want to get an execution plan for the longer query to see if it's really as bad as it looks; the query optimizer might do a better job than the code would indicate.

CONTACT_ADDRESS_ID = Extent2. CONTACT_ADDRESS_ID = Extent3. CONTACT_ADDRESS_ID = Extent4.

CONTACT_ADDRESS_ID = Extent2.

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.

Related Questions