DTO Templates

Posts   
 
    
KastroNYC
User
Posts: 96
Joined: 23-Jan-2006
# Posted on: 25-Jan-2007 21:16:25   

I saw a thread about this and checked the SDK documentation but I didn't see anything related to this matter. Where can I get these templates?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 26-Jan-2007 02:24:22   

Could you post which thread you are refering too?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39621
Joined: 17-Aug-2003
# Posted on: 26-Jan-2007 10:45:37   

These werent' released as a public download but were posted on the forums, see: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=6261

Frans Bouma | Lead developer LLBLGen Pro
KastroNYC
User
Posts: 96
Joined: 23-Jan-2006
# Posted on: 29-Jan-2007 19:11:30   

I took the code from your post in that thread and created a .lpt template out of it but I get an error when trying to generate code inside of llblgen using the template. I'm a newb to template studio so probably an error on my part. Any advise is appreciated.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 30-Jan-2007 01:26:41   

What error do you receive?

KastroNYC
User
Posts: 96
Joined: 23-Jan-2006
# Posted on: 01-Feb-2007 22:13:29   

I receive an end of expression expected error at the If IsSubType line. Any chance of having these templates in the download area? It would be really great to be able to have this work for me. Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14952
Joined: 21-Aug-2005
# Posted on: 02-Feb-2007 08:51:26   

Would you please post the complete error/exception text with the stack trace?

Also which LLBLGen Pro Designer version are you using? (Help->About->Release Date)

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39621
Joined: 17-Aug-2003
# Posted on: 02-Feb-2007 10:58:32   

And the template as you're using it please simple_smile

Frans Bouma | Lead developer LLBLGen Pro
KastroNYC
User
Posts: 96
Joined: 23-Jan-2006
# Posted on: 02-Feb-2007 21:28:51   

The error when compiling in template studio is -

Compile Error (3, 10) CS1002 :; exepected

Here is the first few lines of cs code given back when compiling the template in template studio the entire piece is too long -


using SD.LLBLGen.Pro.ApplicationCore.StoredProcedures;
using RootNamespace;
using If IsSubType;
using SD.LLBLGen.Pro.ApplicationCore.Templates;
using System.Collections;
using EndIf;
using NextForeach;
using SD.LLBLGen.Pro.ApplicationCore.Entities;
using EntityFieldName;
using System;
using If UsePartialClasses;
using SD.LLBLGen.Pro.ApplicationCore.Tasks;
using SD.LLBLGen.Pro.LptParser;
using System.IO;
using CurrentEntityName;
using SD.LLBLGen.Pro.ApplicationCore.TypedLists;
using SD.LLBLGen.Pro.DBDriverCore;
using System.Text;
using SD.LLBLGen.Pro.ApplicationCore.TypedViews;
using SD.LLBLGen.Pro.ApplicationCore;
using SD.LLBLGen.Pro.GeneratorCore;
using CaseCamel EntityFieldName;
using TypeOfField;
using Else;
using System.Collections.Generic;
using If EntityFieldOverrides;
using SuperTypeName;
using Foreach EntityField CrLf;
using System.ComponentModel;


public class ManagerBaseTemplate : ITemplateClass {
    private StreamWriter __outputWriter;
    private IGenerator _executingGenerator;
    private Dictionary<string, TaskParameter> _parameters;
    private object _activeObject;


TEMPLATE - DTOTemplate.lpt


<[ System.IO ]>
<[ System.Text ]>
<[ SD.LLBLGen.Pro.LptParser ]>
<[ SD.LLBLGen.Pro.ApplicationCore ]>
<[ SD.LLBLGen.Pro.ApplicationCore.Entities ]>
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 <[TypeOfField]> _<[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]> 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]> <[TypeOfField]> <[EntityFieldName]>
        {
            get { return _<[CaseCamel EntityFieldName]>;}
            set { _<[CaseCamel EntityFieldName]> = value; }
        }<[NextForeach]>
    }
}

TEMPLATEBINDINGS FILE - DTO.Template.templatebindings


<?xml version="1.0" encoding="utf-8"?>
<templateBindings name="Manager Template" description="Manager templates" precedenceLevel="10" databaseDriverID="2D18D138-1DD2-467E-86CC-4838250611AE" xmlns="http://sd/llblgen/pro/templateBindingsDefinition.xsd">
    <supportedPlatforms>
        <platform name=".NET 2.0" />
    </supportedPlatforms>
    <language name="C#">
        <templateBinding templateID="SD_DTOTemplate" filename="DTO\DTOTemplate.lpt" templateLanguage="C#" />
    </language>
</templateBindings>

Task file - DTO.Template.tasks


<?xml version="1.0"?>
<taskGroup xmlns="http://sd/llblgen/pro/taskGroupElementDefinitions.xsd"
        name="DTO Templates" isOptional ="false" 
        description="General group of tasks which are used DTO templates.">
  <supportedPlatforms>
    <platform name=".NET 2.0" />
  </supportedPlatforms>
  <supportedTemplateGroups>
    <templateGroup name="Adapter" />
  </supportedTemplateGroups>

  <taskGroup name="Create Directories">
    <task name="DTODirectoryCreator" assemblyFilename="SD.LLBLGen.Pro.TaskPerformers.dll" taskPerformerClass="SD.LLBLGen.Pro.TaskPerformers.DirectoryCreator">
      <parameters>
        <parameter name="folderToCreate" defaultValue="DTO" 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>
  </taskGroup>

  <taskGroup name="Create DTO Classes" description="Create DTO Classes">
    <task name="DTOClassCreator" assemblyFilename="SD.LLBLGen.Pro.LptParser.dll" taskPerformerClass="SD.LLBLGen.Pro.LptParser.DotNetTemplateEngine">
      <parameters>
        <parameter isOptional="false" name="destinationFolder" defaultValue="DTO"/>
        <parameter isOptional="false" name="failWhenExistent" defaultValue="false"/>
        <parameter isOptional="false" name="filenameFormat" defaultValue="[elementName]DTO.[extension]"/>
        <parameter isOptional="false" name="templateID" defaultValue="SD_DTOTemplate"/>
        <parameter isOptional="false" name="emitType" defaultValue="allEntities"/>
      </parameters>
    </task>
  </taskGroup>
</taskGroup>

I'm using the latest download of template studio and llblgen (December 6th 2006 build) and the latest version of the manager templates unaltered. Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39621
Joined: 17-Aug-2003
# Posted on: 03-Feb-2007 11:29:05   

Ah I see what's wrong! simple_smile It's a TDL template, not an .lpt template! simple_smile THe statements are TDL statements, please check the <[ ]> syntaxis.

So you can just rename the template file's extension to .template and define the template language as TDL in teh bindings file, and change the task performer so that it uses the CodeEmitter task performer instead (check the tdl consumer base task )

Frans Bouma | Lead developer LLBLGen Pro
KastroNYC
User
Posts: 96
Joined: 23-Jan-2006
# Posted on: 04-Feb-2007 00:09:30   

Awesome! It gives some outputted files now, but these files are somewhat fudged

edit ***

I got everything to work now. Template Studio is really going to be saving me some time. Thanks.