public TypeDataModel(Type clrtype) { p_InnerExtend.SetExtendPropertyValue("ClrType", clrtype); p_InnerExtend.SetExtendPropertyValue("Name", clrtype.GetNameForDatabase()); p_InnerExtend.SetExtendPropertyValue("DisplayName", clrtype.GetDisplayName()); p_InnerExtend.SetExtendPropertyValue("DbType", clrtype.GetDatabaseObjectType()); DataModelHelper.SetExtendProperty_Fields(p_InnerExtend, clrtype); }
/// <summary> /// 使用与model同名称的构造函数 /// </summary> /// <param name="modal"></param> public DatabaseObjectNameAttribute(Type model) : this(DataModelHelper.GetDataModelNameForDatabase(model)) { }
public PropertyDescriptorDataModelField(PropertyDescriptor pd) { #region 基础属性 p_InnerExtend.SetExtendPropertyValue("Name", pd.GetNameForDatabase()); p_InnerExtend.SetExtendPropertyValue("Title", pd.GetDisplayName()); p_InnerExtend.SetExtendPropertyValue("Description", pd.GetDescription()); Type clrType = pd.PropertyType.GetTypeIfIsNullable(); p_InnerExtend.SetExtendPropertyValue("FieldDbType", clrType.GetDbType()); #endregion #region 扩展属性 DataModelHelper.SetExtendProerty_IsSoftDeleteField(p_InnerExtend, pd); DataModelHelper.SetExtendProerty_RowVersion(p_InnerExtend, pd); DataModelHelper.SetExtendProerty_PropertyDescription(p_InnerExtend, pd); DataModelHelper.SetExtendProerty_ClrType(p_InnerExtend, clrType); DataModelHelper.SetExtendProperty_CanbeNull(p_InnerExtend, pd); DataModelHelper.SetExtendProperty_PrimaryKey(p_InnerExtend, pd); DataModelHelper.SetExtendProperty_IndexKey(p_InnerExtend, pd); DataModelHelper.SetExtendProerty_DbFieldValueConvertType(p_InnerExtend, pd); DataModelHelper.SetExtendProperty_DefaultValue(p_InnerExtend, pd); switch (clrType.GetDbType()) { case DbType.String: { DataModelHelper.SetExtendProperty_MaxLength(p_InnerExtend, pd, 50); break; } case DbType.Decimal: { DataModelHelper.SetExtendProperty_DecimalDefine(p_InnerExtend, pd, new DecimalDefine() { DecimalLength = 18, DotLength = 2 }); break; } case DbType.Int16: case DbType.Int32: case DbType.Int64: case DbType.UInt16: case DbType.UInt32: case DbType.UInt64: { DataModelHelper.SetExtendProperty_DbGeneratedDefine(p_InnerExtend, pd); break; } } //数字是否超出范围 NumberType nt = DataValueParase.IsNumberType(clrType); if ((nt != NumberType.Unkown) || (clrType == typeof(DateTime) || clrType == typeof(TimeSpan))) { DataModelHelper.SetExtendProperty_MinMaxExpress(p_InnerExtend, pd); } #endregion }