Generated DTO Class Structure
Per Root Derived Element the LLBLGen Pro Designer generates a separate class file, named after the Root Derived Element. A suffix is appended, if the Derived Model setting in the Project Settings called DerivedElementClassNameSuffix is set to a value other than the empty string. This suffix is appended to the element name which is used to generate the file name, class name and is also used to produce the names for the types namespaces (see example below).
Example
Below an example is given of the root derived element Customer, which contains an embedded derived element, which is created from a valuetype field. The attributes on the elements are automatically added through the default attributes of the DTO Class Model framework. These can be switched off / removed in the Project Settings, the 'Additional Attributes' section below the Derived Model you want to edit the settings for.
Additionally, the code has received a string validation attribute which is added to all string fields based on a rule defined on the additional attribute definition in the project settings. This way a single attribute definition is applied to all string fields, using a macro for the length.
//------------------------------------------------------------------------------
// <auto-generated>This code was generated by LLBLGen Pro v5.0.</auto-generated>
//------------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace NWMM.Dtos.DtoClasses
{
/// <summary> DTO class which is derived from the entity 'Customer'.</summary>
[Serializable]
[DataContract(IsReference=true)]
public partial class Customer
{
/// <summary>Gets or sets the CompanyName field. Derived from Entity Model Field 'Customer.CompanyName'</summary>
[DataMember]
[StringLength(40)]
[Required]
public System.String CompanyName { get; set; }
/// <summary>Gets or sets the ContactName field. Derived from Entity Model Field 'Customer.ContactName'</summary>
[DataMember]
[StringLength(30)]
public System.String ContactName { get; set; }
/// <summary>Gets or sets the ContactTitle field. Derived from Entity Model Field 'Customer.ContactTitle'</summary>
[DataMember]
[StringLength(30)]
public System.String ContactTitle { get; set; }
/// <summary>Gets or sets the VisitingAddress field. </summary>
[DataMember]
public CustomerTypes.VisitingAddress VisitingAddress { get; set; }
}
namespace CustomerTypes
{
/// <summary> DTO class which is derived from the value-type 'AddressVt (VisitingAddress)'.</summary>
[Serializable]
[DataContract(IsReference=true)]
public partial class VisitingAddress
{
/// <summary>Gets or sets the Address field. Derived from Entity Model Field 'AddressVt.Address'</summary>
[DataMember]
[StringLength(60)]
public System.String Address { get; set; }
/// <summary>Gets or sets the City field. Derived from Entity Model Field 'AddressVt.City'</summary>
[DataMember]
[StringLength(15)]
public System.String City { get; set; }
/// <summary>Gets or sets the Country field. Derived from Entity Model Field 'AddressVt.Country'</summary>
[DataMember]
[StringLength(15)]
public System.String Country { get; set; }
/// <summary>Gets or sets the RegionVtField field. </summary>
[DataMember]
public VisitingAddressTypes.RegionVtField RegionVtField { get; set; }
}
namespace VisitingAddressTypes
{
/// <summary> DTO class which is derived from the value-type 'RegionVt (VisitingAddress.RegionVtField)'.</summary>
[Serializable]
[DataContract(IsReference=true)]
public partial class RegionVtField
{
/// <summary>Gets or sets the Region field. Derived from Entity Model Field 'RegionVt.Region'</summary>
[DataMember]
[StringLength(15)]
public System.String Region { get; set; }
}
}
}
}
As you can see, embedded derived elements are contained in namespaces, which makes it easier to refer to these types and also avoids name clashes between embedded derived elements with the same in different root derived elements: multiple Root Derived Elements can now contain an embedded derived element called VisitingAddress, without problems.