Template editing tutorials, howtos, examples

Posts   
 
    
BHerbert
User
Posts: 12
Joined: 16-Jul-2011
# Posted on: 16-Jul-2011 10:17:54   

Hi I am using LLBLGEN for NHibernate code generation and need to edit the templates to get the desired DAL classes generated, problem is there is no SDK docs for the template objects used or even examples i have seen yet demonstrating sample templates or code snippets ! cry right now i am using .net reflector to look through the library based on the errors from designer when generating code rage Anyway i am new to the template thing wink please direct me in the right way where to get available materials on this !

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 16-Jul-2011 11:04:48   

BHerbert wrote:

Hi I am using LLBLGEN for NHibernate code generation and need to edit the templates to get the desired DAL classes generated, problem is there is no SDK docs for the template objects used or even examples i have seen yet demonstrating sample templates or code snippets ! cry

Why do you need to alter the templates to get the classes generated? The classes are generated. What exactly do you need changed?

Other than that, there's the SDK docs, which document the template system and the 'LLBLGen Pro v3.1 designer / algorithmia assemblies reference manual' which describes the objects used in the templates. I think you missed that one. simple_smile It describes all objects used in the templates, and should help you understand where to obtain meta-data.

Frans Bouma | Lead developer LLBLGen Pro
BHerbert
User
Posts: 12
Joined: 16-Jul-2011
# Posted on: 16-Jul-2011 11:30:06   

Otis wrote:

BHerbert wrote:

Hi I am using LLBLGEN for NHibernate code generation and need to edit the templates to get the desired DAL classes generated, problem is there is no SDK docs for the template objects used or even examples i have seen yet demonstrating sample templates or code snippets ! cry

Why do you need to alter the templates to get the classes generated? The classes are generated. What exactly do you need changed?

Other than that, there's the SDK docs, which document the template system and the 'LLBLGen Pro v3.1 designer / algorithmia assemblies reference manual' which describes the objects used in the templates. I think you missed that one. simple_smile It describes all objects used in the templates, and should help you understand where to obtain meta-data.

Was trying to change the Mapping generation to add .Length() ! Didn't see were to change this from the designer properties ! How can i do that with out altering the templates ?

Below is what i have changed (template: entityFluentMapping.lpt, line 430) //sb.AppendFormat(".Access.CamelCaseField(Prefix.Underscore);{0}", Environment.NewLine);

        // Added to cater for DB column text length (Herbert 15/07/2011)
        sb.Append(".Access.CamelCaseField(Prefix.Underscore)");
        if(field.FieldType.RepresentedType == typeof(string))
        {
            sb.AppendFormat(".Length({0})", field.MaxLength.ToString());
        }
        sb.AppendFormat(";{0}", Environment.NewLine);
Walaa avatar
Walaa
Support Team
Posts: 14986
Joined: 21-Aug-2005
# Posted on: 18-Jul-2011 09:44:33   

Did this change solve your problem?

So what's the need for this, in the first place? i.e. Why do you want tot add the .Length(xx)? We might consider adding this to the template if it serves a justified purpose.

BHerbert
User
Posts: 12
Joined: 16-Jul-2011
# Posted on: 18-Jul-2011 10:41:13   

Walaa wrote:

Did this change solve your problem?

So what's the need for this, in the first place? i.e. Why do you want tot add the .Length(xx)? We might consider adding this to the template if it serves a justified purpose.

Well all database types char, nvarchar, varchar, text are mapped to the .Net string type. For instances where i am projecting an entitycollection to a datatable, i will need to add the type maximum length rule to the table column and i also need to apply the precison on numerical types Reason is i am passing these datatable objects to a foxpro environment client so if i don't clearly define the dataset schema table column rules then the foxpro cursur will pick a default type for that column i.e if string has no maxlength tag its converted to a memo and for the numerical types all data values are given default number of precison not based on the underlying column data maximum precison number so i need to pick this info from the class metadata when projecting to a datatable !

It would be best if you give us a visual select tab to add these optional properties to the mappings files rather than one having to edit the template coz these are optional properties not customization of templates ?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 18-Jul-2011 10:56:26   

The meta-data like length, precision, scale and the like in nhibernate mapping files aren't used by nhibernate for o/r mapping, only for schema creation, hence we don't emit them. That said, we did receive feedback to have these elements in the mapping files for purposes like yours, or other, and we have planned to add this in v3.5

Frans Bouma | Lead developer LLBLGen Pro