No loading on a Property

Nov 24, 2010 at 6:27 PM

I need to load an object one Property which is the Data. Mainly im trying to extract all the headers.

So far ive got 4 fields ID, Name, Data, GUID. My Data is currently a filestream that can have huge amount of Data and of course i dont want to download it every time i just wanna show the list of files i have.

The exact operations i wanna do are as follow : Select all properties except the data. Select the data of one file when i ask for it. Insert a new file (only name and data required as the others are identity). Delete a file. Update the file name.

Id like to do that avoiding using extreme hack methods which i did already and was successful. Id like to stick to the architecture of csla.

Im able to download all the headers using linq but i cant get the EntityKey that way which makes me unable to update a file name afterwards.


The best solution that i would see if there were a lazy loading on a property such that when i ask for the Data of my object then it goes to the database get it, otherwise it is never dowloaded.

Any suggestion?

Nov 25, 2010 at 7:36 AM

Hi Stephane. 

You can create two classes: one for metadata management (ID, Name, GUID) and one for file management.

Lets say your tablename is "Files" and it contains following columns: ID, Name, Data, GUID.

Drop your table on the model designer and select EditableRoot as CSLA template. Then select Data column and set CSLAGetter and CSLASetter to none. This class will be used for metadata editing.

After that, write new class "FileDataManager" by hand. This  class would contain only static methods used for loading and saving file data to the database. You can use CslaCommand objects for implementation.

You can also add Lazy Property to the Files class if you want....