I have itemMap class
public class ItemMap : ClassMap<Item>
{
public ItemMap()
{
Table("item");
Id(x => x.Id).GeneratedBy.Identity().Column("id");
Map(x => x.Inserted).Column("inserted").Not.Nullable()
}
}
What are the options of getting table name "item" from the code using C# reflection?
Here is an extensionmethod for getting the tablename for a mapped class:
public static string GetTableNameFromClass<T>(this ISession session)
{
var abstractEntityPersister = session.SessionFactory.GetClassMetadata(typeof(T)) as AbstractEntityPersister;
return abstractEntityPersister?.TableName.Replace("[", "").Replace("]", "");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.