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, lets say I have a Planner.cs 1:N Attachment.cs . When I eager load the IEnumerable<Planner> with its Attachments by a certain date I do want to load only the id + name of the attachment not the byte[] AttachmentDocument.
Attachment.cs int Id {get;set;} string Name {get;set;} [ExcludeFromEagerLoad] Byte[] Document {get;set;}
The reason why I want this, is that a Day has many many Dates and each one can have many images/documents. I do not want them to eager, it must be lazy load. Only load it when the customer really wants to show it. I know there is an ORM out there who can do this (forgot the name). So maybe your lightspeed can do this too?
|
|
|
Yes, you can do this by specifying the EagerLoad attribute on the property with a named aggregate: [EagerLoad(AggregateName = "WithDocumentData")] (Note the attribute must be set on the backing field, not the property.) Then the Document column will be excluded from queries, and will be loaded only when the Document property is accessed. I.e. EagerLoad with an aggregate on a field actually results in that field being lazy-loaded by default. Furthermore, if for a particular query you know that you *will* be needing the document data, you can make it eager-load after all by specifying the aggregate name, by setting the AggregateName on the Query object if using the core API, or by using the WithAggregate() operator if using LINQ. |
|
|
Just to add to this, if you are lazy-loading a column then the property getter must be implemented using Entity.Get rather than directly accessing the backing field: public Byte[] Document { If you're using the designer it does this automatically for you. |
|
|
nice nice :) above your free edition gift with 8 tables max. |
|