日期:2014-05-20 浏览次数:20973 次
foreach (PropertyInfo fi in typeof(Product).GetProperties()) { if (fi.GetCustomAttributes(false).Length > 0&&fi.GetCustomAttributes(false)[0] is ColumnAttribute) { ColumnAttribute c = fi.GetCustomAttributes(false)[0] as ColumnAttribute; if (c.IsPrimaryKey) { string a = fi.Name; } } }