コード例 #1
0
        public override JoinQueryResult Visit(RootQueryExpression exp)
        {
            Type           type           = exp.ElementType;
            TypeDescriptor typeDescriptor = EntityTypeContainer.GetDescriptor(type);

            string  explicitTableName = exp.ExplicitTable;
            DbTable dbTable           = typeDescriptor.Table;

            if (explicitTableName != null)
            {
                dbTable = new DbTable(explicitTableName, dbTable.Schema);
            }
            string alias = this._queryModel.GenerateUniqueTableAlias(dbTable.Name);

            DbTableSegment tableSeg = CreateTableSegment(dbTable, alias, exp.Lock);

            DbTable            aliasTable = new DbTable(alias);
            ComplexObjectModel model      = typeDescriptor.GenObjectModel(aliasTable);

            //TODO 解析 on 条件表达式
            var          scopeParameters = this._scopeParameters.Clone(this._conditionExpression.Parameters.Last(), model);
            DbExpression condition       = GeneralExpressionParser.Parse(this._conditionExpression, scopeParameters, this._queryModel.ScopeTables);

            DbJoinTableExpression joinTable = new DbJoinTableExpression(this._joinType.AsDbJoinType(), tableSeg, condition);

            JoinQueryResult result = new JoinQueryResult();

            result.ResultModel = model;
            result.JoinTable   = joinTable;

            return(result);
        }
コード例 #2
0
        protected override DbExpression[] VisitNew(NewExpression exp)
        {
            DbExpression[] ret = new DbExpression[exp.Arguments.Count];
            for (int i = 0; i < exp.Arguments.Count; i++)
            {
                var dbExp = GeneralExpressionParser.Parse(exp.Arguments[i], this._scopeParameters, this._scopeTables);
                ret[i] = dbExp;
            }

            return(ret);
        }
コード例 #3
0
        public override DbExpression[] Visit(Expression exp)
        {
            switch (exp.NodeType)
            {
            case ExpressionType.Lambda:
                return(this.VisitLambda((LambdaExpression)exp));

            case ExpressionType.New:
                return(this.VisitNew((NewExpression)exp));

            default:
            {
                var dbExp = GeneralExpressionParser.Parse(exp, this._scopeParameters, this._scopeTables);
                return(new DbExpression[1] {
                        dbExp
                    });
            }
            }
        }
コード例 #4
0
        public override JoinQueryResult Visit(RootQueryExpression exp)
        {
            Type           type           = exp.ElementType;
            TypeDescriptor typeDescriptor = EntityTypeContainer.GetDescriptor(type);

            string  explicitTableName = exp.ExplicitTable;
            DbTable dbTable           = typeDescriptor.Table;

            if (explicitTableName != null)
            {
                dbTable = new DbTable(explicitTableName, dbTable.Schema);
            }
            string alias = this._resultElement.GenerateUniqueTableAlias(dbTable.Name);

            DbTableSegment          tableSeg = CreateTableSegment(dbTable, alias, exp.Lock);
            MappingObjectExpression moe      = new MappingObjectExpression(typeDescriptor.Definition.Type.GetConstructor(Type.EmptyTypes));

            DbTable table = new DbTable(alias);

            foreach (PropertyDescriptor item in typeDescriptor.PropertyDescriptors)
            {
                DbColumnAccessExpression columnAccessExpression = new DbColumnAccessExpression(table, item.Column);
                moe.AddMappingMemberExpression(item.Property, columnAccessExpression);

                if (item.IsPrimaryKey)
                {
                    moe.PrimaryKey = columnAccessExpression;
                }
            }

            //TODO 解析 on 条件表达式
            var          scopeParameters = this._scopeParameters.Clone(this._conditionExpression.Parameters.Last(), moe);
            DbExpression condition       = GeneralExpressionParser.Parse(this._conditionExpression, scopeParameters, this._resultElement.ScopeTables);

            DbJoinTableExpression joinTable = new DbJoinTableExpression(this._joinType.AsDbJoinType(), tableSeg, condition);

            JoinQueryResult result = new JoinQueryResult();

            result.MappingObjectExpression = moe;
            result.JoinTable = joinTable;

            return(result);
        }
コード例 #5
0
 public static DbExpression Parse(LambdaExpression filterPredicate, ScopeParameterDictionary scopeParameters, StringSet scopeTables)
 {
     return(GeneralExpressionParser.Parse(BooleanResultExpressionTransformer.Transform(filterPredicate), scopeParameters, scopeTables));
 }
コード例 #6
0
 public static DbExpression Parse(LambdaExpression filterPredicate, ScopeParameterDictionary scopeParameters, KeyDictionary <string> scopeTables)
 {
     return(GeneralExpressionParser.Parse(ExpressionVisitorBase.ReBuildFilterPredicate(filterPredicate), scopeParameters, scopeTables));
 }