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
|
I'm running into some issues whereby eager loading (WithAggregate) isn't working when I do a Select() projection into a custom (non-lightspeed) object. The linq query I am running is below:
The "unusual" thing I am doing here is projecting into a object that LightSpeed has no knowledge of (TransactionInfo). This object is read-only - it's only used used to display some data on a webpage. I am using a custom object as I want to have some specific serialization happen to the object when converting it to JSON. The custom object makes this job cleaner and simpler. Is projecting into a non-lightspeed object possible? |
|
|
Hi Brad, Projecting into an arbitrary object is fine - this is very normal behavior :) What is the issue you are running into? You also mentioned you are also running into issues with Eager Loading not working. Eager loads are not applied when projecting as they only apply when dealing when we are loading full entities (e.g. by using UnitOfWork.Find<>) so using WithAggregate here isn't applicable.
|
|
|
As Jeremy has noted, projecting into a non-entity type is fine, but when the projection contains data from multiple tables, we perform the projection client-side -- but we don't eager load when a projection is in play. A workaround for this is to explicitly perform a LINQ join:
This avoids both the client-side projection and the lazy-load problem. |
|
|
Thanks guys - this was exactly what I needed! |
|
|
|
|