The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Need the Name of the Primary Key Column During Custom Class Generation

Last post 05-27-2008, 10:59 AM by MBonafe. 3 replies.
Sort Posts: Previous Next
  •  05-27-2008, 10:20 AM 9495

    Need the Name of the Primary Key Column During Custom Class Generation

    I am modifiying the custom class generator (in a new file of course) and I need the name of the primary key column.

    I am trying to create a line of code that looks similar to this:

    Code:
    [some esEntity].SetColumn("<%=primary key field Name%>", <%=primary key field Name%>.Value);
     Anyone have suggestions? 
    Thanks
    Mark
  •  05-27-2008, 10:31 AM 9497 in reply to 9495

    Re: Need the Name of the Primary Key Column During Custom Class Generation

    This is a sample from our esEntity template in the generated folder.

     

    Code:
    foreach(EntitySpaces.MetadataEngine.IColumn col in table.PrimaryKeys)
    {
    %><%=comma%><%
    %><%=
    esMeta.esPlugIn.CSharpToSystemType(col) + " " + esMeta.esPlugIn.ParameterName(col)%><%
    comma = ", ";
    }%>)

     

    Notice that there is a primary keys collection (could be a composite key) and if you want the name of the Column you should use Column.Alias which will be the column name unless you have defined an alias.   


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  05-27-2008, 10:47 AM 9500 in reply to 9497

    Re: Need the Name of the Primary Key Column During Custom Class Generation

    Thanks Mike

    I think I can get it to work except for one problem.  I am running a Custom class generator, not a Generated class generator.  And - I'm having a problem accessing the ITable object.  esMeta.Input["Table"] is null.


    Thanks
    Mark
  •  05-27-2008, 10:59 AM 9501 in reply to 9500

    Re: Need the Name of the Primary Key Column During Custom Class Generation

    Oh boy...

    Ok, I must not understand how to make a new custom template.  I just copied the entire "Custom Entity" template to a new file and the new file won't compile.  I get the infamous "object reference not set..." error.

    What am I missing?


    Thanks
    Mark
View as RSS news feed in XML