Ejemplo n.º 1
0
        /// <summary>
        /// 获取符合条件的模型属性集合
        /// </summary>
        /// <param name="modelType"></param>
        /// <param name="exp"></param>
        /// <returns></returns>
        PropertyInfo[] IDbMappingHandler.GetPropertyCollection(Type modelType, Expression <Func <DbColumnAttribute, bool> > exp)
        {
            Dictionary <PropertyInfo, DbColumnAttribute> columnMappings = DbMappingCache.GetColumns(modelType);

            if (null == columnMappings)
            {
                return(null);
            }

            if (null == exp)
            {
                return(columnMappings.Keys.ToArray());
            }
            else
            {
                List <PropertyInfo> pis = new List <PropertyInfo>();
                foreach (var item in columnMappings.Values.Where(exp.Compile()))
                {
                    pis.Add(columnMappings.FirstOrDefault(d => d.Value.DbColumnName == item.DbColumnName).Key);
                }

                return(pis.ToArray());
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取SqlServer数据库的实例名称
 /// </summary>
 /// <param name="modelType"></param>
 /// <returns></returns>
 string IDbMappingHandler.GetDatabaseName(Type modelType)
 {
     return(DbMappingCache.GetDBDatabase(modelType).Name);
 }