Reputation: 1
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?
Upvotes: 0
Views: 260
Reputation: 1810
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("]", "");
}
Upvotes: 1