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 have a table where one of the columns is an image. I would like to get the data from that table, but selectively load the byte array from that column only when I need it. Is there a way to programaticly tell lightspeed which columns to select when getting a record from the database, without having to have 2 different objects in my model, one with, and one without the image column? |
|
|
Yes, there is, and it is -- paradoxically -- controlled by the EagerLoad attribute. What you need to do is mark the fields that should be conditionally loaded with the [EagerLoad(AggregateName="...")] attribute. (In the designer, select the property and enter a name in the Aggregates box.) By default, such fields will be lazy loaded -- LightSpeed will not fetch them from the database when you load the entity, but will go back and get them when they are accessed. But if you know you *are* going to need those fields, you can specify Query.AggregateName (or use the LINQ WithAggregate() operator). Setting this tells LightSpeed to eager-load all fields with the specified aggregate name. Thus: [EagerLoad("WithImage")] // designer: set Aggregates to WithImage Finally, if you are writing your classes by hand, for a lazy-loaded field the property getter must call Get(field) rather than just returning the field value. The designer automatically does this for you. For more info, see Help Topics > LightSpeed > Querying in the user guide. |
|