if (field == null)
{
throw new Exception("属性名" + propertyName + "不存在");
}
object[] objs = field.GetCustomAttributes(typeof(FieldAttribute), true);
if (objs.Length <= 0)
{
throw new Exception("类体属性名" + propertyName + "没有标识FieldAttribute属性");
}
else
{
object obj = objs[0];
FieldAttribute fieldAttribute=(FieldAttribute)obj;
fieldAttribute.FieldValue=field.GetValue(this,null);
return fieldAttribute;
}
}
}
创建数据实体:
[Table("Wincms_Dictionary")] ///映射到数据库的Wincms_Dictionary表
public class Wincms_Dictionary : BaseEntity
{
private int _DictionaryId;
public Wincms_Dictionary()
{
}
[Field("DictionaryId",DbType.Int32)] ///映射到数据库的Wincms_Dictionary表中的字段
public int DictionaryId
{
get { return this._DictionaryId; }
set
{
this._DictionaryId = value;








