private DatabaseEntityDef CreateModelDef(Type modelType) { DatabaseEntityDef modelDef = new DatabaseEntityDef(); #region 自身 modelDef.EntityType = modelType; modelDef.EntityFullName = modelType.FullName; //modelDef.PropertyDict = new Dictionary<string, DatabaseEntityPropertyDef>(); #endregion #region 数据库 if (_entitySchemaDict.TryGetValue(modelType.FullName, out EntitySchema dbSchema)) { modelDef.IsTableModel = true; modelDef.DatabaseName = dbSchema.DatabaseName; modelDef.TableName = dbSchema.TableName; modelDef.DbTableDescription = dbSchema.Description; modelDef.DbTableReservedName = _databaseEngine.GetReservedStatement(modelDef.TableName); modelDef.DatabaseWriteable = !dbSchema.ReadOnly; } else { modelDef.IsTableModel = false; } #endregion #region 属性 foreach (PropertyInfo info in modelType.GetTypeInfo().GetProperties()) { IEnumerable <Attribute> atts2 = info.GetCustomAttributes(typeof(EntityPropertyIgnoreAttribute), false).Select <object, Attribute>(o => (Attribute)o); if (atts2 == null || atts2.Count() == 0) { DatabaseEntityPropertyDef propertyDef = CreatePropertyDef(modelDef, info); modelDef.PropertyDict.Add(propertyDef.PropertyName, propertyDef); modelDef.FieldCount++; } } #endregion return(modelDef); }