/// <summary> /// 填充数据层实际类型 /// </summary> /// <param name="rowIndex"></param> private void FillDBRealType(int rowIndex) { int len = Convert.ToInt32(gvField.Rows[rowIndex].Cells["ColLength"].Value); DbType type = (DbType)EnumUnit.GetEnumInfoByName(typeof(DbType), gvField.Rows[rowIndex].Cells["ColParamType"].Value.ToString()).Value; gvField.Rows[rowIndex].Cells["DBRealType"].Value = _ida.DBTypeToSQL(type, len); }
/// <summary> /// 转换成字段信息 /// </summary> /// <returns></returns> public EntityParam ToParamInfo() { EntityParam ep = new EntityParam(); ep.FieldName = FieldName; ep.Description = Summary; ep.ParamName = ParamName; ep.PropertyName = PropertyName; ep.SqlType = (DbType)EnumUnit.GetEnumInfoByName(typeof(DbType), DbType).Value; ep.PropertyType = EntityPropertyType; //ep.AllowNull = IsNullProperty(_fInfo.MemberTypeShortName); ep.AllowNull = AllowNull; ep.ReadOnly = ReadOnly; ep.Description = Description; return(ep); }
/// <summary> /// 填充字段信息 /// </summary> /// <param name="entity"></param> /// <param name="lstParam"></param> private void FillParams(EntityConfig entity, List <EntityParam> lstParam, List <TableRelationAttribute> lstRelation) { foreach (EntityParamField param in entity.EParamFields) { if (!param.IsGenerate) { continue; } DbType dbt = (DbType)EnumUnit.GetEnumInfoByName(typeof(DbType), param.DbType).Value; EntityParam pInfo = new EntityParam("", param.ParamName, "", dbt, param.EntityPropertyType, param.Summary, param.Length, param.AllowNull, param.ReadOnly); lstParam.Add(pInfo); } foreach (EntityRelationItem relation in entity.ERelation) { if (relation.IsToDB && relation.IsGenerate && relation.IsParent) { EntityConfig parent = new EntityConfig(relation.FInfo.MemberType, DesignerInfo); if (parent == null) { continue; } EntityParamField childProperty = entity.GetParamInfoByPropertyName(relation.SourceProperty); if (childProperty == null) { continue; } EntityParamField parentProperty = parent.GetParamInfoByPropertyName(relation.TargetProperty); if (parentProperty == null) { continue; } lstRelation.Add(new TableRelationAttribute("", "", entity.TableName, parent.TableName, childProperty.ParamName, parentProperty.ParamName, "", relation.IsParent)); } } }
/// <summary> /// 初始化属性 /// </summary> private void InitPropertys() { _lstProperty = new List <UIModelItem>(); List <ClrProperty> lstClrProperty = EntityConfig.GetAllMember <ClrProperty>(_classType, true); EntityConfig entity = new EntityConfig(_classType, DesignerInfo); Stack <EntityConfig> stkEntity = EntityConfig.GetEntity(entity, DesignerInfo); foreach (ClrProperty property in lstClrProperty) { UIModelItem item = new UIModelItem(property); EntityParamField finfo = EntityConfig.FindParamInfoByName(stkEntity, item.PropertyName); if (finfo != null) { bool isPK = EnumUnit.ContainerValue((int)finfo.EntityPropertyType, (int)EntityPropertyType.PrimaryKey); TableInfo tinfo = new TableInfo(isPK, finfo.ParamName, finfo.Length, finfo.ReadOnly, (DbType)EnumUnit.GetEnumInfoByName(typeof(DbType), finfo.DbType).Value); item.TabInfo = tinfo; } else { EntityRelationItem rel = EntityConfig.FindRelInfoByName(stkEntity, item.PropertyName); if (rel != null) { RelationInfo rinfo = new RelationInfo(rel.TargetProperty, rel.SourceProperty, rel.IsParent, rel.TypeName, rel.TypeFullName); item.RelInfo = rinfo; } } _lstProperty.Add(item); } }