Exemplo n.º 1
0
        public DbMetaDataReader(Type type)
        {
            var extendPropertys = ExtendProperty.GetPropertys(type);

            mds = extendPropertys
                  .Where(ep => ep.MetaData != null && ep.MetaData.GetType() == typeof(DbMetaData))
                  .Select(ep => ep.MetaData as DbMetaData).ToList();
        }
Exemplo n.º 2
0
 public Unit(BattleScene battle, UnitCreateData data)
 {
     this.battle   = battle;
     this.baseInfo = data.info;
     this.baseProp = data.prop;
     this.extProp  = new ExtendProperty <int>();
     this.InitUnit();
 }
Exemplo n.º 3
0
 /// <summary>
 /// 获取物理模型中对应属性的元数据信息,既属性对应的数据库中的表列信息。
 /// </summary>
 /// <param name="dboType"></param>
 /// <param name="propertyName">属性名</param>
 /// <returns></returns>
 public static MetaData GetMetaData(Type dboType, string propertyName)
 {
     lock (LockObject)
     {
         SetTableModelCable(dboType);
         var ep = ExtendProperty.GetProperty(dboType, propertyName);
         return(ep.MetaData);
     }
 }
Exemplo n.º 4
0
        internal static Column CreateColumn(this ExtendProperty property, XElement schema)
        {
            ExtendProperty extProperty       = property as ExtendProperty;
            XElement       extEntitySchema   = schema.GetEntitySchema(extProperty.Entity);
            XElement       extPropertySchema = extEntitySchema.Elements(SchemaVocab.Property).First(x => x.Attribute(SchemaVocab.Name).Value == extProperty.Property);
            string         table             = extEntitySchema.Attribute(SchemaVocab.Table).Value;

            return(new Column(table, extPropertySchema.Attribute(SchemaVocab.Column).Value));
        }
Exemplo n.º 5
0
 /// <summary>
 /// 获取物理模型类型的表名
 /// </summary>
 /// <param name="dboType"></param>
 /// <returns></returns>
 public static string GetTableName(Type dboType)
 {
     lock (LockObject)
     {
         SetTableModelCable(dboType);
         var ep        = ExtendProperty.GetProperty(dboType, "TableName");
         var tableName = ep.DefaultValue.ToString();
         return(tableName);
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// 获取物理模型类型的主键数组
 /// </summary>
 /// <param name="dboType"></param>
 /// <returns></returns>
 public static string[] GetKeys(Type dboType)
 {
     lock (LockObject)
     {
         SetTableModelCable(dboType);
         var ep   = ExtendProperty.GetProperty(dboType, "Keys");
         var keys = ep.DefaultValue as string[];
         return(keys);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// 得到主键参数
        /// </summary>
        static private List <Parameter> GetKeysParams <TModel>(TModel entity, string paramPrefix) where TModel : DbObject
        {
            var extendPropertys = ExtendProperty.GetPropertys(typeof(TModel));
            var pds             = extendPropertys
                                  .Where(ep => ep.MetaData != null && ep.MetaData.GetType() == typeof(DbMetaData) && ((DbMetaData)ep.MetaData).IsKey)
                                  .Select(ep => new Parameter(paramPrefix + ((DbMetaData)ep.MetaData).FieldName,
                                                              FormatValue(entity.GetValue(ep)),
                                                              ((DbMetaData)ep.MetaData).Type)).ToList();

            return(pds);
        }
Exemplo n.º 8
0
        public Query(string entity, string select, string filter, string orderby, XElement schema, ParameterCollection parameters)
        {
            Entity     = entity;
            Schema     = new XElement(schema);
            Parameters = parameters;

            //
            Select = new Select(string.IsNullOrWhiteSpace(select) ? "*" : select, Entity, Schema);
            List <string>        parameterList = new List <string>();
            IEnumerable <string> properties    = Select.Properties;

            if (!string.IsNullOrWhiteSpace(filter))
            {
                Filter     = new Filter(filter, Entity, Schema);
                properties = properties.Union(Filter.Properties);
                parameterList.AddRange(Filter.Parameters);
            }
            if (!string.IsNullOrWhiteSpace(orderby))
            {
                Orderby    = new Orderby(orderby, Entity, Schema);
                properties = properties.Union(Orderby.Orders.Select(o => o.Property));
            }

            //
            List <Property> propertyList = new List <Property>();
            XElement        entitySchema = Schema.GetEntitySchema(Entity);

            foreach (string property in properties)
            {
                Property oProperty;

                XElement propertySchema = entitySchema.Elements(SchemaVocab.Property).FirstOrDefault(x => x.Attribute(SchemaVocab.Name).Value == property);
                if (propertySchema == null)
                {
                    if (!property.Contains("."))
                    {
                        throw new SyntaxErrorException(string.Format(ErrorMessages.NotFoundProperty, property, Entity));
                    }

                    oProperty = ExtendProperty.GenerateExtendProperty(property, Entity, schema);
                }
                else
                {
                    oProperty = FieldProperty.Create(property, entity, Schema);
                }

                propertyList.Add(oProperty);
            }

            Properties = new PropertyCollection(propertyList, this);

            Parameters.UnionParameters(parameterList);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 得到字段对应的类型属性名
        /// </summary>
        /// <param name="dboType"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public static string GetPropertyName(Type dboType, string fieldName)
        {
            lock (LockObject)
            {
                SetTableModelCable(dboType);
                string result = null;
                var    ps     = ExtendProperty.GetPropertys(dboType);
                var    exp    = ps.FirstOrDefault(ep => (ep.MetaData as DbMetaData) != null ? (ep.MetaData as DbMetaData).FieldName == fieldName : false);
                if (exp != null)
                {
                    result = exp.PropertyName;
                }

                return(result);
            }
        }