CodeSmith Community
Your Code. Your Way. Faster!

Generating CRUD procedure using StoredProcedures.cst

Latest post 05-22-2008 12:01 PM by hampole. 3 replies.
  • 04-04-2008 3:49 PM

    • hampole
    • Not Ranked
    • Joined on 01-30-2008
    • Posts 6
    • Points 150

    Generating CRUD procedure using StoredProcedures.cst

     I am trying to generate CRUD procedures on a table having column data type VarBinary(max). It seems the template is generating only "VarBinary" and not with max length. I thought I will debug this and tried to build the project under Codesmith projects - SqlSchemaProvider and getting the error "Cryptographic failure while signing assembly" and it is not able to find codesmith.snk file. Could someone help me how to build the project and If I have to fix the issue about the procedure, Do I need to fix it in SqlSchemaProvider.cs file. Please help me. I am using Codesmith prof.V4.1.

    Second issue, I am not able to debug the template with VS2008. 

    Thanks,

    Ravi 

    • Post Points: 65
  • 04-08-2008 10:03 AM In reply to

    • blake05
    • Top 25 Contributor
    • Joined on 04-03-2008
    • Wisconsin
    • Posts 422
    • Points 7,725

    Re: Generating CRUD procedure using StoredProcedures.cst

    Hey Ravi,

    As to your previous post pertaining to the codesmith.snk file.

    "Inside the template you are trying to build, open up the AssemblyInfo.cst file (if it is there) and remove the AssemblyKeyFile attribute.

    If your template doesn’t contain an AssemblyInfo.cst, then check to see if it is generating a project file with the CodeSmith.snk (Strong Name Key) inside of ItemGroup. If you find this XML node in your project file remove it, as your assembly doesn’t need to be signed."

    You shouldn't need to change any of code in the SqlSchemaProvider.cs file.

    As to your second question, have you checked out the debugging documentation in the CodeSmith User's Guide?  To access this, open CodeSmith Studio and hit the F1 shortcut key. Look for "Advanced Template Syntax" on the left sidebar and under that take a look at "Debugging Templates"

     

     If you are still unable to debug with vs2008. Please leave your repo steps, and I'll try to reproduce it locally.

    Thanks
    -Blake Niemyjski

    Blake Niemyjski

    CodeSmith Tools, LLC Support Specialist

    Blog: http://windowscoding.com/blogs/blake/

    ----------------------------------------------------------------------
     Member of the .NetTiers team | Visit http://www.nettiers.com
    ----------------------------------------------------------------------

    Filed under:
    • Post Points: 5
  • 05-22-2008 10:17 AM In reply to

    • Eck
    • Not Ranked
    • Joined on 05-22-2008
    • Posts 1
    • Points 35

    Re: Generating CRUD procedure using StoredProcedures.cst

    I'm having the same problem.  We've got a password field that is encrypted into a varbinary(100) column in our user table, but CodeSmith generates just:

    @Password varbinary

    instead of

    @Password varbinary(100)

     The result is that when someone resets their password, the update stored procedure truncates the data to just one binary character. It's as if the stored procedure took

    @Password varbinary(1)

     I'd prefer not to modify the CodeSmith application since it seems like a bug in CodeSmith rather than the StoredProcedures.cst file. 

     - Eck

    • Post Points: 35
  • 05-22-2008 12:01 PM In reply to

    • hampole
    • Not Ranked
    • Joined on 01-30-2008
    • Posts 6
    • Points 150

    Re: Generating CRUD procedure using StoredProcedures.cst

    Reply |Contact |Answer

     You need to fix it in BaseTemplates project. The file is SqlCodeTemplate.cs file and this is what I have done. Here is the code snippet.

            public string GetSqlParameterStatement(ColumnSchema column, bool isOutput)
            {
                string param = "@" + column.Name + " " + column.NativeType;
                if (column.NativeType.ToUpper() == "VARBINARY" && column.Size == -1) param += "(max)";
                if (column.NativeType.ToUpper() == "VARBINARY" && column.Size > 0) param += "(" + column.Size + ")";
                if (!this.IsUserDefinedType(column))
    .....

    Once you have the new dll "SchemaExplorer.SqlSchemaProvider.dll", copy to program files/codesmith/../AddIns

    Ravi 

    • Post Points: 5
Page 1 of 1 (4 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems