Exemplo n.º 1
0
        /// <summary>
        ///   //进行实体类的字段同数据库的列明进行绑定
        /// </summary>
        public static void InitDbFildInfo <TEntity>(EntityMappingInfo <TEntity> mapInfo) where TEntity : class
        {
            Type type = typeof(TEntity);

            tableName = mapInfo.TableName;
            //表名
            if (tableName.Length == 0)
            {
                tableName = type.Name;
            }
            //数据列
            foreach (EntityFiledMappingInfo <TEntity> item in mapInfo?.EntityFildMappingList)
            {
                PropertyInfo propertyInfo = type.GetProperty(item.EntityFiledName);

                if (propertyInfo == null)
                {
                    continue;
                }
                if (!propertyClmDict.Keys.Contains(propertyInfo))
                {
                    propertyClmDict.Add(propertyInfo, item.ColumnName);
                }
            }
            type.GetProperties().
            Where(info => !propertyClmDict.Keys.Contains(info)).
            ToList <PropertyInfo>().
            ForEach(u =>
            {
                if (!propertyClmDict.Keys.Contains(u))
                {
                    propertyClmDict.Add(u, u.Name);
                }
            });
        }
Exemplo n.º 2
0
 public virtual void OnModelBuilder <T>(EntityMappingInfo <T> mapInfo) where T : class
 {
     this.Set <T>(mapInfo);
 }
Exemplo n.º 3
0
 public void Set <T>(EntityMappingInfo <T> mapInfo) where T : class
 {
     DbEntity <T> .InitDbFildInfo <T>(mapInfo);
 }