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
|
Hello, Is there a way to perform this query on LightSpeed (either using LINQ or QueryExpressions) like a single DB server call (not using separate DB server calls for calculation count of ContainerItems for each Container:
|
|
|
You should be able to issue an equivalent query via the querying API using something like this:
|
|
|
Thanks a lot for your reply. This code produces t-sql script:
Script is almost successful, but doesn't return ContainerItems count, maybe some alias should be added for this value. |
|
|
Are you able to post the code you are using? It would seem you are missing the following line:
In particular make sure you are using the generic version of Entity.Attribute specifying the ContainerItem type.
|
|
|
The code is exactly the same as you've posted for me:
And t-sql which has been produced (copied directly from sql profiler):
I'm using MS SQL server 2008. Any ideas what kind of problem could be inside query expressions? |
|
|
Thats very odd as Ive constructed a model here based on whats present in the query and using the code above it runs fine for me and generates the correct statement with the COUNT() selection. There is a ContainerItemId property on your ContainerItem object correct? If so could you send through your model and I can check it here.
|
|
|
Thanks a lot for your help. The problem was that I have ContainerItem table primary key column named ContainerItemId in the DB (the model was generated based on existent DB) and after generation it was mapped as Id entity property in the model. The correct query expression for me is:
This query expression generates exactly what I need. Thanks once more, sorry because of my inattention. |
|