I am trying to generate some custom entities and custom method to get data from database.
ListByPrimaryKey – the column name sometimes is “ID”, “pid”, “id”, etc.
How can you detect that a column is a primary key using C#, using T4 templates?
protected void GenerateListByMethods( Table table)
{
WriteLine("#region ListBy\n");
WriteLine("\n\tpublic List<"+Prefix+table.Name+"> ListAll()\n\t{\n\t " +
this.RepositoryNotification +
"\n\t\t\t return Ctx.GetAll().ToList().ToCustomList<"+table.Name+","+Prefix+table.Name+">();\n\t}\n");
foreach (Column column in table.Columns)
{
switch(column.DataType.Name)
{ // do something
How can you write an extension method for column.DataType.IsPrimaryKey?
If you are using SQL SERVER try to run either of the querys
or