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
|
Given the following code
I would expect the SQL to be
however, it is
The double condition on the actual SQL looks suspicious... (Especially given there are two values in the original array) |
|
|
Yes that does look odd - presumably there is a grouping query prior to the query above though? If not then the grouping will be being performed client side which would indicate there is a client side component to your query so check if that might be the case. Ive created a comparable query against a test model here but it is executing as I would expect - is it possible for you to send through a small repro example of this and I can have more of a look into what might be going on and if we need to make a fix for this.
|
|
|
Here is the reproduction. You were right, there are two queries generated.
|
|
|
So that output is what I would expect and doesn't contain the duplicate criteria you saw originally - any thoughts on how to reproduce that? The way the translation for a LINQ group by occurs is that we have to issue a grouping query to fetch the grouping keys and then issue a query to fetch the entities associated with those keys so you will see 2 queries as above. It would be nicer to perform this as a single query but currently this is just how it works because we have to perform the queries using the underlying querying API.
|
|
|
Oh dear, that was the problem I was having. That table has a large number of rows in it so fetching each row is not ideal. Any idea on what the best work around is? Both stored procedure and inline SQL seem a bit tacky. I guess inline sql will allow the work around to be kept local to the code executing the query. Cheers Andy |
|
|
You should definitely try handling this using the querying API directly where you can be a bit smarter than our translation engine about constructing the query since you know you dont actually need to deal with entities for handling the projection so you should be able to write this as a single query. Try something like:
Hopefully that should do the trick.
|
|
|
Excellent, that will do the trick. Thanks |
|