This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I am using Lightspeed v4.0.1476.20948 (nightly 6 sept 2012) on the Nortwind database. I try to join on the same table twice:
I expect the following result:
But I get this result:
Can you explain this? Is this a bug? |
|
|
It uses the following query:
As you can see, it only selects t1.ProductName, not t2.ProductName, and it uses t1.ProductName in the WHERE instead of t2.ProductName. |
|
|
This type of translation is not well handled by our LINQ provider as we dont have enough context to correctly determine which instance of Product is being referred to. Generally if you are writing these types of queries you will want to use the native querying API where you can more precisely specify the aliases being used in a query. We do have an existing item on our backlog to improve this but this will be part of a much wider effort to update the LINQ provider and its handling of alias tracking within queries. This is something we will be looking at in a later release. In this particular case you can get this to work by making sure you align the name of the lambda parameters with the name of the property you are selecting into. e.g.
Note that where you had p => in your original query these are now product1 => and product2 => respectively in the updated query above. This allows us to determine which instance of the joined entity type you are referring to in the LINQ translation.
|
|