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
|
Tested on: todays nightly build and 14/06 nightly. I am having a serious (showstopper) problem with a query which joins the view attached to an entity with another entity. I mocked up an example app to demonstrate the problem - it is attached and it inserts example data. CategoryView is a View attached to a CategoryInCategory table, representing many to many relation of Category table entries. The query is fairly simple - reads from view with condition, slelects one relation from view and also adds a condition on top of it, returning only one row:
The SQL is:
The errors are:
So there are couple problems with it and I wonder why there are 3 queries and a first query does not use view - only view has nested information about the hierarchy of objects? This looks completely wrong and number of fetched objects is far exceeding what's expected (if it worked). The expected and working query would look like below:
Why the view is not treated as a table in the first place, it would probably solve some of the issues above... There is another issue, possibly related (example 1). When I select from view LightSpeed ignores Eager Load Collection property, possibly also Aggregates. Seemingly the view is not used like a table but as a source of Ids for further querying. When do you plan to change it so the view will behave just like a normal table ? |
|
|
Thanks for reporting this and the repro project - We are having a look at this and I will post an update once we have an update.
|
|
|
Thanks, looking forward to it. |
|
|
Hi Jeremy, Do you possibly have any updates on this issue? Thanks |
|
|
Unfortunately nothing yet. I am still working on trying to get this resolved.
|
|
|
Hello again, Sorry to ask but we just kick started .Net development and within a week we would need to make some models using views functional. I suspect the change to make views behave like tables should not be that dramatic but I did not yet had a chance to look into the internals of Lightspeed structures. Do you think the feature can be ready (bug-free) soon or should we rather look for alternative solutions? Many thanks, |
|
|
Sorry for the delay in getting back to you on this. The problem is stemming from the way in which we translate the LINQ statement into a LightSpeed query, in particular because you have introduced a traversal (.Select(x => x.Category)) which is confusing the translated query into targeting the Category entity rather than the CategoryView view over CategoryInCategory entity. I am still looking into getting the translation issue resolved but since it is not an easy fix I still cant offer any timeframe around this. As a simple workaround for this you can switch to forcing enumeration after expressing the view w/ criteria part of the query and then have the remainder evaluated server side. To mitigate against additional queries set the "Eager Load BackReference" property of the CategoryInCategory's Category association to true which will force the associated Category to be eager loaded with the result from the view call. e.g. From the repro project, we would introduce a .ToList() call on the second line of the LINQ statement:
In terms of views providing the same functionality when working with tables, this is already the case. The only change we make when a view name is supplied for the query is to use that as an effective alias for the table name.
|
|
|
Thanks Jeremy, sorry for not replying sooner - we have decided to switch back to Entity Framework (code first) as for now we only use SQL Server, our application model is not that complex but the queries are (and will be even more when it comes to statistics calculation and retrieval). Thanks for your support. |
|