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
|
Hi, I have this LINQ query: from t in uow.Tickets join uc in uow.Users on t.CreatedById equals u.Id Join ul in uow.Users on t.UpdatedById equals ul.Id where u.Name.Contains("John") && ul.Name.Contains("John") select t.Number;
As you can see, the Ticket table is join to the same table twice through different foreign keys. If I try to execute the query without where clause, the LS sql generated code is exactly what I want. This is also true if in the where clause, I work with any other methods other than the string contrains method. (Note that I don't have tried all methods that exist :)) In my case, the LS sql generated code use the same alias for both conditions instead of using for example t0 for the first criterias and t1 for the second criterias of my where clause.
Example of current generated code: SELECT Ticket.Number FROM Ticket INNER JOIN User t0 ON t0.Id = Ticket.CreatedById INNER JOIN User t1 ON t1.Id = Ticket.UpdatedById WHERE t1.Name LIKE '%John%' AND t1.Name LIKE '%John%'
Here is what I think should be a good result:
SELECT Ticket.Number FROM Ticket INNER JOIN User t0 ON t0.Id = Ticket.CreatedById INNER JOIN User t1 ON t1.Id = Ticket.UpdatedById WHERE t0.Name LIKE '%John%' AND t1.Name LIKE '%John%'
Thank you very much. |
|
|
Thanks for drawing our attention to this. There will be a fix in the next nightly build. |
|
|
Hi. Today i write the same query and have this problem. How to solve this problem? |
|
|
Can you elaborate on the query you are writing and the problem you are seeing? The specific problem mentioned above was fixed a while ago.
|
|