Following are the 3 steps i followed to create DTOs and i am stuck, would someone please let me know if these are the right steps and what are the following steps after these:
Step 1. Create a new file called DTO.Template in the folder "C:\Program Files\Solutions Design\LLBLGen Pro v2.0\Templates\SharedTemplates\Net2.x\C#".
Step 2. Paste this in this template file:
using System;
using System.ComponentModel;
using System.Collections;
using System.Runtime.Serialization;
using <[RootNamespace]>.EntityClasses;
namespace <[RootNamespace]>.DTOClasses
{
/// <summary>
/// DTO class for the entity '<[CurrentEntityName]>'.
/// </summary>
[Serializable]
public <[If UsePartialClasses]>partial <[EndIf]>class <[CurrentEntityName]>DTO <[ If IsSubType ]>: <[ SuperTypeName ]>DTO<[ EndIf]>
{
#region Class Member Declarations
<[Foreach EntityField CrLf]> private <[If IsNullable]><[If IsValueType]>Nullable<<[TypeOfField]>><[Else]><[TypeOfField]><[EndIf]><[Else]><[TypeOfField]><[EndIf]> _<[CaseCamel EntityFieldName]>;<[NextForeach]>
#endregion
/// <summary>
/// CTor
/// </summary>
public <[CurrentEntityName]>DTO()
{
}
/// <summary>
/// CTor which initializes the DTO with values from its corresponding entity
/// </summary>
/// <param name="entityInstance">The entity instance which holds the values for this DTO</param>
public <[CurrentEntityName]>DTO(<[CurrentEntityName]>Entity entityInstance)<[ If IsSubType ]> : base(entityInstance)<[ EndIf]>
{
<[Foreach EntityField CrLf]> _<[CaseCamel EntityFieldName]> = entityInstance.<[EntityFieldName]>;<[NextForeach]>
}
/// <summary>
/// Creates a new entity instance and copies over the values of this DTO
/// </summary>
public <[CurrentEntityName]>Entity ToEntity()
{
return ToEntity(new <[CurrentEntityName]>Entity());
}
/// <summary>
/// Copies over the values of this DTO into the entity passed in.
/// </summary>
public <[CurrentEntityName]>Entity ToEntity(<[CurrentEntityName]>Entity toFill)
{
<[Foreach EntityField CrLf]> toFill.<[EntityFieldName]> = _<[CaseCamel EntityFieldName]>;<[NextForeach]>
<[ If IsSubType ]> base.ToEntity(toFill);<[ EndIf]>
return toFill;
}
<[Foreach EntityField CrLf]>
/// <summary> The <[EntityFieldName]> property of the Entity <[CurrentEntityName]></summary>
public <[If EntityFieldOverrides]>override<[Else]>virtual<[EndIf]> <[If IsNullable]><[If IsValueType]>Nullable<<[TypeOfField]>><[Else]><[TypeOfField]><[EndIf]><[Else]><[TypeOfField]><[EndIf]> <[EntityFieldName]>
{
get { return _<[CaseCamel EntityFieldName]>;}
set { _<[CaseCamel EntityFieldName]> = value; }
}<[NextForeach]>
}
}
Step 3. In the file SD.Tasks.SelfServicing.Tasks file in the folder C:\Program Files\Solutions Design\LLBLGen Pro v2.0\Tasks
added this:
<!-- folder creation tasks -->
<task name="SD.Tasks.SelfServicing.DTOClassesDirectoryCreator" assemblyFilename="SD.LLBLGen.Pro.TaskPerformers.dll"
taskPerformerClass="SD.LLBLGen.Pro.TaskPerformers.DirectoryCreator" description ="Creates the DTOClasses folder." isOptional="false">
<supportedPlatforms/>
<supportedTemplateGroups>
<templateGroup name="SelfServicing"/>
</supportedTemplateGroups>
<dependencies/>
<parameters>
<parameter name="folderToCreate" defaultValue="DTOClasses" isOptional="false" description="The folder to create"/>
<parameter name="failWhenExistent" defaultValue="false" isOptional="true" description="Flag to signal what to do when the folder already exists. Overrules clearWhenExistent" valueType="boolean"/>
<parameter name="clearWhenExistent" defaultValue="false" isOptional="true" description="Flag to signal if an existing folder has to be cleared first. Overruled by failWhenExistent" valueType="boolean"/>
</parameters>
</task>
In the above posts Frans said:
So, go to the Drivers\SqlServer\Templates folder and open CSharpTemplateset.config in notepad. (there's also a tutorial for this in the manual).
Right below the last <templateBinding> tag you add:
Code:
<templateBinding templateID="EntityDTOAdapterTemplate" templateFilename="......\SharedTemplates\C#\entityDTO.template" />
The template I specified above should be saved in the file entityDTO.template and be stored in the folder SharedTemplates\C#
I looked for this file CSharpTemplateset.config but did not find it.
Could anyone let me know what are the next steps also if there is anything not right in the above steps please let me know.
Thanks