【发布时间】:2017-03-26 18:23:22
【问题描述】:
我正在使用 Dapper 和 Dapper.Contrib 来映射数据库中的对象。
我有一个类名,我为这个类定义了表名,因为它与实际的类名不同。
类:
[Table("tblUser")]
public class User
{
public int Id { get; set; }
public string Title { get; set; }
}
如何获取表名设置的表数据注解属性?
编辑:
我已经使用了以下功能来使其正常工作
var tAttribute =
(TableAttribute)typeof(T).GetCustomAttributes(typeof(TableAttribute), true)[0];
tableName = tAttribute.Name;
【问题讨论】:
标签: data-annotations dapper typeof