1

Closed

Primary Key Columns with Name "ID"

description

Hi All
 
I look after a database which has the convention of using "ID" as the Primary Key for all columns.
 
In using the Nusoft Framework (15770), I have set extended properties for all the columns to be "TableName + Id" which works nicely until the GetColumnNameWithoutIdSuffix function is called in entity.generated.cst which returns "" for the ColumnName.
 
Can I suggest the following fix?
 
 
public string GetColumnNameWithoutIdSuffix(ColumnSchema column)
{
string name = "";
string columnName = column.Name;
if(column.ExtendedProperties["NSFx_EntityPropertyName"] != null) {
    columnName = (string)column.ExtendedProperties["NSFx_EntityPropertyName"].Value;
}
 
if(columnName.EndsWith("id", System.StringComparison.CurrentCultureIgnoreCase))
{
    name = GetPascalCaseName(columnName.Substring(0, columnName.Length - 2));
}
else
{
    name = GetPascalCaseName(columnName);
}
return name;
}
Closed Apr 4, 2008 at 3:16 AM by RossCode
Version release.

comments

RossCode wrote Mar 5, 2008 at 11:46 PM

Good catch. I'll change it slightly to use the appropriate method that handles the column name - GetPropertyName.

wrote Mar 5, 2008 at 11:46 PM

RossCode wrote Mar 5, 2008 at 11:47 PM

Fixed with checkin #15851

wrote Mar 5, 2008 at 11:47 PM

wrote Apr 4, 2008 at 3:16 AM

wrote Feb 14, 2013 at 12:16 AM

wrote May 16, 2013 at 4:27 AM