public void GetTableInfo(Type t, TableInfo ti) { //Table Name ti.TableName = Util.GetAttributeValue<ComponentModel.TableNameAttribute, string>(t, "TableName", ti.TableName + "s"); ti.TableName = _tablePrefix + ti.TableName; //Primary Key ti.PrimaryKey = Util.GetPrimaryKeyName(t.GetTypeInfo()); ti.AutoIncrement = true; }
public static TableInfo FromPoco(Type t) { var tableInfo = new TableInfo(); // Get the table name var a = t.GetCustomAttributes(typeof(TableNameAttribute), true); tableInfo.TableName = a.Length == 0 ? t.Name : (a[0] as TableNameAttribute).Value; // Get the primary key a = t.GetCustomAttributes(typeof(PrimaryKeyAttribute), true); tableInfo.PrimaryKey = a.Length == 0 ? "ID" : (a[0] as PrimaryKeyAttribute).Value; tableInfo.SequenceName = a.Length == 0 ? null : (a[0] as PrimaryKeyAttribute).SequenceName; tableInfo.AutoIncrement = a.Length == 0 ? true : (a[0] as PrimaryKeyAttribute).AutoIncrement; // Set autoincrement false if primary key has multiple columns tableInfo.AutoIncrement = tableInfo.AutoIncrement ? !tableInfo.PrimaryKey.Contains(',') : tableInfo.AutoIncrement; return tableInfo; }
public virtual void GetTableInfo(Type t, TableInfo ti) { }