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
|
Hey Guys, Is it possible to model a stored procedure call to populate aggregates as well as the entity type set up in lightspeed
IE I have entity X which is loaded by stored procedure in certain cases, in these cases I also want to populate Y which is a related entity.
Is this possible?
Many thanks Owen |
|
|
Afraid not. You can do this using eager loading in a table select, but we don't have a way of loading multiple result sets from sprocs. Sorry. |
|
|
Understood. Is there any way of taking the entities loaded and loading various attached entities with one hit to the db rather than iterating over all the entities?
O |
|
|
I wouldn't want to do this every time, instead would look to do it only on specific queries. |
|
|
A child collection is automatically loaded in one hit. Multiple entities of the same type can be loaded in one hit but may require you to compose a query e.g. object[] neededWidgetIds = thingsFromSproc.Select(e => e.WidgetId).ToArray(); This will allow you to refer to anyThingFromSproc.Widget without incurring a trip to the database because the associated Widget will now be in the identity map and LightSpeed can retrieve it from there. Entities of different types cannot be loaded in one hit. |
|
|
Thank you ivan, that's just what i wanted to know. |
|
|
Since it's been a few years, and a few versions, I thought I'd ask... Is this still the case? That is, is it still not possible to populate multiple entities from a single stored proc call's multiple result sets? Cheers. EDIT: Just saw your twitter reply on the same topic, pasted here for future generations:
|
|
|
I started using Dapper for a similar types of queries. Loads into the LightSpeed models just fine. You perform a SELECT that repeats the Id for each type of entity, and it fills and switches entity when it sees the new Id field. I suggested a similar enhancement to LightSpeed 5 here: |
|