比如
[Table(Name="dbo.User")]
public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
{
...
[Column(Storage="_Id", AutoSync=AutoSync.OnInsert, DbType="BigInt NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
public long Id
{
...
}
...
}
请教:我如何才能获取到 User.Id 的DbType的值
谢谢
[Table(Name="dbo.User")]
public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
{
...
[Column(Storage="_Id", AutoSync=AutoSync.OnInsert, DbType="BigInt NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
public long Id
{
...
}
...
}
请教:我如何才能获取到 User.Id 的DbType的值
谢谢
先行谢过
object[] attributes = ss.GetCustomAttributes(true);
for (int i = 0, j = attributes.Length; i < j; i++)
{
if (attributes[i] is ColumnAttribute)
{
ColumnAttribute ca = attributes[i] as ColumnAttribute;
Response.Write(ca.DbType);
}
}
var attrInfo = typeof(User).GetProperty("Id").GetCustomAttributes(typeof(ColumnAttribute), true)[0] as ColumnAttribute;
Response.Write(attrInfo.DbType);
只要确认 Id 属性(字段)存在就可以直接使用。
还没人回答,哪怕顶一次也好,让我咋个结贴哦
否则你需要自己写SQL语句到数据库直接获取。