示例#1
0
        /// <summary>
        /// 获取基本类型的sql表达式节点
        /// </summary>
        /// <param name="memberExpression">成员表达式</param>
        /// <returns>基本类型的sql表达式节点</returns>
        protected ISqlBuilder GetColumnBuilder(MemberExpression memberExpression)
        {
            //若Mapper容器为空
            if (_mapperContainer == null)
            {
                //则直接获取针对 WITH AS 临时表的sql表达式
                return(new SqlBuilder("t.{0}", memberExpression.Member.Name));
            }
            //若不为空,则获取针对表的sql表达式
            // 获取当前实体类型的Table元数据解析器
            ITableMapper tableMapper = _mapperContainer.GetTableMapper(memberExpression.Expression.Type);
            // 获取columnMapper
            IColumnMapper columnMapper = tableMapper.GetColumnMapper(memberExpression.Member.Name);

            // 获取sql列节点生成器
            return(_commandTreeFactory.GetColumnBuilder(tableMapper.Header.TableAlias, columnMapper.ColumnName));
        }
示例#2
0
        /// <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));
        }
示例#3
0
 /// <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;
 }
示例#4
0
 /// <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();
 }