Any support for modifiers (protected, private, internal) on generated DTO properties?

Posts   
 
    
RobP
User
Posts: 5
Joined: 30-Apr-2012
# Posted on: 01-May-2012 00:18:47   

Hello,

I found this thread: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=9062&HighLight=1 , but it did not come to a final conclusion.

I am interested in hiding certain fields and, in addition, preventing them from being fetched by default. My use case is as follows:

I have some tables which contain file information + binary data containing the file contents. I would like to retrieve the file info without the binary data, then implement a lazy load property/function which will retrieve only the binary data as needed. Here's an example of my model:


class SomeFile
{
  public string FileName { get; set; }
  public string FileType { get; set; }
  public DateTime CreatedAt { get; set; }
  public byte[] Data { get; set; }
}

Does LLBLGen provide a way that I can retrieve all fields EXCEPT "byte[] Data" when I fetch the entity? Ideally, I would like to accomplish this with a single class instead of making 2 copies of "SomeFile", one with Data and one without.

I'm using v3.1 with Adapter mode.

Thanks in advance,

-- Rob

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 01-May-2012 07:02:24   

Hi Rob,

There is a better thing that access modifiers, and that is Including/Excluding fields from fetches.

You can exclude some large fields from fetch, and later on you can fetch those fields as needed.

David Elizondo | LLBLGen Support Team
RobP
User
Posts: 5
Joined: 30-Apr-2012
# Posted on: 01-May-2012 11:11:02   

Thanks David,

Using the Exclude/Include fields does seem to address my example with SomeFile, I'll use that.

Now, regarding access modifiers, is there any support in LLBLGen for customization here? Or is each Property in my DTO required to be public?

As another example, I have many tables with Create/Update timestamps (DateCreated, DateUpdated), which I am setting systematically by overriding OnBeforeSaveEntity in DataAccessAdapter. I don't actually care to have these publicly exposed as Properties at all in my DTO, but at least I would like to have the setter be restricted.

Is there any facility for this?

Regards, -- Rob

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-May-2012 06:51:52   

Hi Rob,

LLBLGen doesn't have DTO templates built-in. So I guess you have installed the additional DTO templates. If you want to exclude some fields or change the visibility of the fields you have to change the template and have some kind of setting on each field you want to exclude from the DTO. Read the SDK docs if you want to learn how to use custom settings.

On v3.x you can signal that some field is not public. Just go to Edit your entity, then to "Code gen info" sub-tab, select the field in the element selector and turn off the "Field property is public" setting. However this could affect your generated code, you won't be able to access that property on your own code. Also you have to modify the DTO templates anyway to exclude such private fields.

If I didn't understood your scenario, please elaborate more.

David Elizondo | LLBLGen Support Team