<[Foreach UniqueConstraint]> does not expand

Posts   
 
    
pietdejong
User
Posts: 6
Joined: 14-Apr-2010
# Posted on: 26-Dec-2010 10:44:23   

3.0 Final - TRIAL, December 8th, 2010 Adapter, Mysql, Target Framework: LLBLGen Pro Runtime

Hi All, I want to auto generate methods which will return entities by using unique constraint. as follows by using custom class LLBLGenHelper: DetailEntity e = LLBLGenHelper.Detail.GetDetailEntityByUCEmail ( "email@gmail.com" );

which will either return the entity or null if not exists.

To start, I see in the file entityIncludeAdapter.template the following code, which I have copied and pasted directly without modification into my custom template:


<[Foreach UniqueConstraint]>
        /// <summary> Method which will construct a filter (predicate expression) for the unique constraint defined on the fields:
        /// <[Foreach UniqueConstraintEntityField Comma]><[EntityFieldName]> <[NextForeach]>.</summary>
        /// <returns>true if succeeded and the contents is read, false otherwise</returns>
        public IPredicateExpression ConstructFilterForUC<[Foreach UniqueConstraintEntityField]><[EntityFieldName]><[NextForeach]>()
        {
            IPredicateExpression filter = new PredicateExpression();
<[Foreach UniqueConstraintEntityField]>         filter.Add(new FieldCompareValuePredicate(this.Fields[(int)<[CurrentEntityName]>FieldIndex.<[EntityFieldName]>], null, ComparisonOperator.Equal));
<[NextForeach]>             return filter;
        }

When I copy + paste this into my custom template, the generated output does not seem to get generated correctly, the result is:



<[ForeachUniqueConstraint]>
        /// <summary> Method which will construct a filter (predicate expression) for the unique constraint defined on the fields:
        ///  .</summary>
        /// <returns>true if succeeded and the contents is read, false otherwise</returns>
        public IPredicateExpression ConstructFilterForUC()
        {
            IPredicateExpression filter = new PredicateExpression();
            filter.Add(new FieldCompareValuePredicate(this.Fields[(int)DetailFieldIndex.], null, ComparisonOperator.Equal));
            return filter;
        }

Other code in my custom template is expanded fine, so the template configuration seems ok.

Any ideas ? Many thanks.

pietdejong
User
Posts: 6
Joined: 14-Apr-2010
# Posted on: 26-Dec-2010 10:59:06   

The task looks as follows:


<task name="PDJ.Tasks.LLBLHelper.ClassesGenerator" assemblyFilename="SD.LLBLGen.Pro.TaskPerformers.dll" 
            taskPerformerClass="SD.LLBLGen.Pro.TaskPerformers.CodeEmitter" description="Generates the helper classes" isOptional="true">
            <supportedPlatforms/>
            <supportedTemplateGroups/>
            <supportedFrameworks>
                <framework name="LLBLGen Pro Runtime Framework"/>
            </supportedFrameworks>
            <dependencies>
                <dependency name="PDJ.Tasks.LLBLHelper.DirectoryCreator"/>
            </dependencies>
            <parameters>
                <parameter name="destinationFolder" defaultValue="[dbgenericSubFolder]\LLBLHelperClasses" isOptional="false" description="The folder to generate the code in"/>
                <parameter name="filenameFormat" defaultValue="[elementName].[extension]" isOptional="false" description="The destination file format specification"/>
                <parameter name="templateID" defaultValue="PDJ_LLBLHelper" isOptional="false" description="The ID of the template to use." valueType="templateID"/>
                <parameter name="emitType" defaultValue="allEntities" isOptional="false" description="The type of code generation to perform." valueType="emitType"/>
                <parameter name="templateBindingDefinitionName" defaultValue="" isOptional="true" description="The name of the TemplateBindings from which to pick the templateID specified. Specifying this parameter will always force the templateID to be picked from the templateBindings with the name specified."/>
                <parameter name="failWhenExistent" defaultValue="false" isOptional="true" description="Flag to signal what to do when the destination file already exists." valueType="boolean"/>
            </parameters>
        </task>

I have tried changing emitType to "generic" but that did not seem to have any effect.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-Dec-2010 20:25:24   

I think you are missing the last <[NextForeach]> statement to close the <[Foreach UniqueConstraint]> loop. Use allEntities in emitType.

David Elizondo | LLBLGen Support Team
pietdejong
User
Posts: 6
Joined: 14-Apr-2010
# Posted on: 27-Dec-2010 05:18:46   

Yes, thanks!