/// <summary> /// 扩展方法: 获取Column元数据解析器 /// </summary> /// <param name="mapperContainer">Mapper容器</param> /// <param name="memberExpression">指定对象成员的表达式</param> /// <returns>Column元数据解析器</returns> public static IColumnMapper GetColumnMapper(this IMapperContainer mapperContainer, MemberExpression memberExpression) { //获取当前实体类型的Table元数据解析器 ITableMapper tableMapper = mapperContainer.GetTableMapper(memberExpression.Expression.Type); //获取Column元数据解析器 return(tableMapper.GetColumnMapper(memberExpression.Member.Name)); }
public MapperContext( IMapperContainer container, Parameters parameters) { _container = container; _creator = parameters.Creator ?? Activator.CreateInstance; _updater = parameters.Updater ?? (i => { }); _deleter = parameters.Deleter ?? (i => { }); }
/// <summary> /// 创建Lambda表达式解析对象 /// </summary> /// <param name="parameterFactory">sql参数创建对象</param> /// <param name="commandTreeFactory">创建Sql命令生成树的工厂</param> /// <param name="mapperContainer">Mapper对象容器</param> public WhereVisitor(IParameterFactory parameterFactory, ICommandTreeFactory commandTreeFactory, IMapperContainer mapperContainer) { //非空检查 Check.ArgumentNull(parameterFactory, nameof(parameterFactory)); Check.ArgumentNull(commandTreeFactory, nameof(commandTreeFactory)); //赋值 _parameterFactory = parameterFactory; _commandTreeFactory = commandTreeFactory; _mapperContainer = mapperContainer; }
/// <summary> /// 创建对象访问关联 /// </summary> /// <param name="property">关联对象属性</param> /// <param name="mapperContainer">Mapper容器</param> /// <param name="accessorLinkers">子属性的访问关联数组</param> public AccessorLinker(PropertyInfo property, IMapperContainer mapperContainer, params AccessorLinker[] accessorLinkers) { //非空检查 Check.ArgumentNull(property, nameof(property)); Check.ArgumentNull(mapperContainer, nameof(mapperContainer)); //赋值 this.PropertyName = property.Name; this.EntityAccessor = ObjectAccessor.GetAccessor(property.PropertyType); this.TableMapper = mapperContainer.GetTableMapper(property.PropertyType); this.AccessorLinkers = accessorLinkers; }
/// <summary> /// 创建获取表达式解析器的工厂 /// </summary> /// <param name="parameterFactory">参数创建器</param> /// <param name="commandTreeFactory">创建Sql命令生成树的工厂</param> /// <param name="mapperContainer">Mapper容器</param> public WhereVisitorFactory(IParameterFactory parameterFactory, ICommandTreeFactory commandTreeFactory, IMapperContainer mapperContainer = null) { //非空检查 Check.ArgumentNull(parameterFactory, nameof(parameterFactory)); Check.ArgumentNull(commandTreeFactory, nameof(commandTreeFactory)); //赋值 _parameterFactory = parameterFactory; _commandTreeFactory = commandTreeFactory; _mapperContainer = mapperContainer; _locaker = new object(); _whereVisitors = new Dictionary <ExpressionType, WhereVisitor>(); }
/// <summary> /// 创建去除重复项查询数据源 /// </summary> /// <param name="mapperContainer">Mapper容器</param> /// <param name="commandTreeFactory">创建CommandTree的工厂</param> /// <param name="dbHelper">操作数据库的DbHelper</param> public DbDistinctQuery(IMapperContainer mapperContainer, ICommandTreeFactory commandTreeFactory, DbHelper dbHelper) : base(mapperContainer, commandTreeFactory, dbHelper) { }
/// <summary> /// 初始化 /// </summary> /// <param name="mapperContainer">Mapper容器</param> /// <param name="commandTreeFactory">创建CommandTree的工厂</param> /// <param name="dbHelper">操作数据库的DbHelper</param> public DbQuery(IMapperContainer mapperContainer, ICommandTreeFactory commandTreeFactory, DbHelper dbHelper) : base(mapperContainer, commandTreeFactory, dbHelper) { this.objectAccessor = ObjectAccessor.GetAccessor(typeof(TEntity)); }
/// <summary> /// 创建实体数据操作对象 /// </summary> /// <param name="factory">查询数据源创建工厂</param> /// <param name="dbHelper">数据库操作对象</param> /// <param name="commandTreeFactory">创建CommandTree的工厂</param> /// <param name="mapperContainer">mapper容器</param> public DbOperator(IDbFactory factory, DbHelper dbHelper, ICommandTreeFactory commandTreeFactory, IMapperContainer mapperContainer) { //非空检查 Check.ArgumentNull(factory, nameof(factory)); Check.ArgumentNull(dbHelper, nameof(dbHelper)); Check.ArgumentNull(commandTreeFactory, nameof(commandTreeFactory)); Check.ArgumentNull(mapperContainer, nameof(mapperContainer)); //赋值 this.Factory = factory; this.DbHelper = dbHelper; this.CommandTreeFactory = commandTreeFactory; this.TableMapper = mapperContainer.GetTableMapper(typeof(TEntity)); //初始化sql this._insertSql = this.GetInsertSql(); this._insertAllSql = this.GetInsertAllSql(); this._deleteSql = this.GetDeleteSql(); this._updateSql = this.GetUpdateSql(); this._updateAllSql = this.GetUpdateAllSql(); }
public MapperContext( IMapperContainer container) : this(container, new Parameters()) { }
public DataContext(IMapperContainer container) { Container = container; }
/// <summary> /// 创建DbList对象 /// </summary> /// <param name="factory">创建数据源的工厂</param> /// <param name="dbHelper">DbHelper</param> /// <param name="commandTreeFactory">创建CommandTree的工厂</param> /// <param name="mapperContainer">mapper容器</param> public DbList(IDbFactory factory, DbHelper dbHelper, ICommandTreeFactory commandTreeFactory, IMapperContainer mapperContainer) : base(factory, dbHelper, commandTreeFactory, mapperContainer) { this.modifyLocker = new object(); this.PropertyLinkers = new PropertyLinker[0]; }
/// <summary> /// 创建Lambda表达式解析对象 /// </summary> /// <param name="parameterFactory">sql参数创建对象</param> /// <param name="commandTreeFactory">创建Sql命令生成树的工厂</param> /// <param name="mapperContainer">Mapper对象容器</param> public MethodCallWhereVisitor(IParameterFactory parameterFactory, ICommandTreeFactory commandTreeFactory, IMapperContainer mapperContainer) : base(parameterFactory, commandTreeFactory, mapperContainer) { }
protected MapBlockBase(IMapperContainer container) { _container = container; }
/// <summary> /// 创建统计查询类 /// </summary> /// <param name="mapperContainer">Mapper容器</param> /// <param name="commandTreeFactory">创建CommandTree的工厂</param> /// <param name="dbHelper">操作数据库的DbHelper</param> public DbScalar(IMapperContainer mapperContainer, ICommandTreeFactory commandTreeFactory, DbHelper dbHelper) : base(mapperContainer, commandTreeFactory, dbHelper) { }
/// <summary> /// 创建二叉树表达式解析对象 /// </summary> /// <param name="parameterFactory">sql参数创建对象</param> /// <param name="commandTreeFactory">创建Sql命令生成树的工厂</param> /// <param name="mapperContainer">Mapper容器</param> /// <param name="factory">创建表达式解析器的工厂</param> public BinaryWhereVisitor(IParameterFactory parameterFactory, ICommandTreeFactory commandTreeFactory, IMapperContainer mapperContainer, IWhereVisitorFactory factory) : base(parameterFactory, commandTreeFactory, mapperContainer) { _factory = factory; }
/// <summary> /// 创建去除TOP选定项查询数据源对象 /// </summary> /// <param name="mapperContainer">Mapper容器</param> /// <param name="commandTreeFactory">创建CommandTree的工厂</param> /// <param name="dbHelper">操作数据库的DbHelper</param> /// <param name="topCount">查询的前几条的元素数量</param> public DbTopSelectedQuery(IMapperContainer mapperContainer, ICommandTreeFactory commandTreeFactory, DbHelper dbHelper, int topCount) : base(mapperContainer, commandTreeFactory, dbHelper) { this.topCount = topCount; }
/// <summary> /// 创建操作数据库的基础对象 /// </summary> /// <param name="mapperContainer">Mapper容器</param> /// <param name="commandTreeFactory">创建CommandTree的工厂</param> /// <param name="dbHelper">操作数据库的DbHelper</param> public DbBase(IMapperContainer mapperContainer, ICommandTreeFactory commandTreeFactory, DbHelper dbHelper) { this.MapperContainer = mapperContainer; this.CommandTreeFactory = commandTreeFactory; this.DbHelper = dbHelper; }
/// <summary> /// 创建带事故执行的实体数据操作对象 /// </summary> /// <param name="factory">数据源创建工厂</param> /// <param name="dbHelper">数据库操作对象</param> /// <param name="commandTreeFactory">创建CommandTree的工厂</param> /// <param name="mapperContainer">mapper容器</param> /// <param name="transaction">事故</param> public DbTransactionOperator(IDbFactory factory, DbHelper dbHelper, ICommandTreeFactory commandTreeFactory, IMapperContainer mapperContainer, IDbTransaction transaction) : base(factory, dbHelper, commandTreeFactory, mapperContainer) { this.transaction = transaction; }
/// <summary> /// Extendable method: 获取对象访问关联对象 /// </summary> /// <param name="propertyLinker">属性关联对象</param> /// <param name="mapperContainer">Mapper容器</param> /// <returns>对象访问关联对象</returns> internal static AccessorLinker ToAccessorLinker(this PropertyLinker propertyLinker, IMapperContainer mapperContainer) { //获取子联访问链接集合 AccessorLinker[] accessorLinkers = propertyLinker.RelationalLinkers.Select(p => p.ToAccessorLinker(mapperContainer)).ToArray(); //创建并返回关联访问链接 return(new AccessorLinker(propertyLinker.Property, mapperContainer, accessorLinkers)); }