Any Code Generation Templates for Csla 3.7 and up

Any Code Generation Templates for Csla 3.7 and up

Old forum URL:

Jav posted on Thursday, October 15, 2009

About a month or so ago I downloaded cslacontrib-59043 (That download link appears to have disappeared now). Since all I needed was to create Properties, Parameters and SafeDataReader fields, I thought I was all set. But a strange thing is happening. In any place a Column name has the word 'Category', it gets eliminated. 'CategoryKey' becomes 'Key', 'RootcategoryKey' becomes RootKey and 'CategoryName' becomes 'Name'. Unfortunately the word 'category' occures in almost all of my tables.
I have looked around to see if I can modify the templates but haven't discovered what to change.
Any ideas would be appreciated. Are there any other C# templates that could do the job. Thanks.

Jav replied on Thursday, October 15, 2009

There is an option for UniqueColumnNames which is supposed to be used only when generating against views or storedprocs.

I added the names my columns to this option. While it didn't work consistently with tables, it does work with storedprocs, and I am assuming the same will be true with views.


rasupit replied on Thursday, October 15, 2009

That's only true if the table name is Category.  By default, any column name contains table name will be shortened.  If you don't like this option, you can search for GetPropertyName method in TemplateBase.cs then remove the lines in red.

public static string GetPropertyName(DataObjectBase col)
    string name = col.Name;

    //ensure first character is capital letter
    name = name.Substring(0, 1).ToUpper() + name.Substring(1);

    //convert ex:START_DATE or Start Date to StartDate
    if (name.IndexOf('_') >= 0 || name.IndexOf(' ') >= 0 || name == name.ToUpper())
        name = CsHelper.MakeProper(name);

    //fix name that contain table prefix
    //ex table:Project column:ProjectName, ProjectDescription
    if(col is ColumnSchema)
        name = name.Replace(((ColumnSchema)col).Table.Name, "");

    if (name.EndsWith("TypeCode"))
        name = name.Substring(0, name.Length - 4);

    if(name.Length == 0)
        throw new Exception("Column " + col.Name + " has resulted blank property name");
    return name;

Jav replied on Sunday, October 18, 2009

Thank you. That was indeed very helpful - and it worked. Thanks also for your tireless contributions.

BTW, I cannot find the download links anymore - has this project been terminated?


JonnyBee replied on Sunday, October 18, 2009


No it's alive and in activity.

Download all code from the "Source Code" folder. On the right hand side you will find "Latest version" and the download button.

Jav replied on Saturday, October 24, 2009

Aah! I found the goldmine. Thank you.


Copyright (c) Marimer LLC