/// <summary> /// 获取列名信息 /// </summary> /// <param name="modelType"></param> /// <param name="propertyName"></param> /// <returns></returns> DbColumnAttribute IDbMappingHandler.GetDbColumnSingle(Type modelType, string propertyName) { Dictionary <PropertyInfo, DbColumnAttribute> columnMappings = DbMappingCache.GetColumns(modelType); if (null == columnMappings) { return(null); } return(columnMappings.FirstOrDefault(d => d.Key.Name == propertyName).Value); }
/// <summary> /// 获取符合条件的列集合信息 /// </summary> /// <param name="modelType"></param> /// <param name="exp"></param> /// <returns></returns> DbColumnAttribute[] IDbMappingHandler.GetDbColumnCollection(Type modelType, Expression <Func <DbColumnAttribute, bool> > exp) { Dictionary <PropertyInfo, DbColumnAttribute> columnMappings = DbMappingCache.GetColumns(modelType); if (null == columnMappings) { return(null); } if (null == exp) { return(columnMappings.Values.ToArray()); } else { return(columnMappings.Values.Where(exp.Compile()).ToArray()); } }
/// <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()); } }