Exemplo n.º 1
0
 internal EntitySetExpression(TableExpression sourceTable, MemberInfo memberInfo, Type entitySetType, BuilderContext builderContext, ExpressionDispatcher dispatcher)
     : base(ExpressionType, entitySetType)
 {
     this.builderContext = builderContext;
     this.EntitySetType = entitySetType;
     this.dispatcher = dispatcher;
     this.sourceTable = sourceTable;
     this.memberInfo = memberInfo;
     ParseExpression(sourceTable);
 }
        IList <InputParameterExpression> BuildExpressionParameters(ExpressionChain expressions, QueryContext queryContext)
        {
            var builderContext     = new BuilderContext(queryContext);
            var previousExpression = ExpressionDispatcher.CreateTableExpression(expressions.Expressions[0], builderContext);

            previousExpression = BuildExpressionQuery(expressions, previousExpression, builderContext);
            BuildOffsetsAndLimits(builderContext);
            // then prepare Parts for SQL translation
            PrepareSqlOperands(builderContext);
            return(builderContext.ExpressionQuery.Parameters);
        }
        /// <summary>
        /// Builds and chains the provided Expressions
        /// </summary>
        /// <param name="expressions"></param>
        /// <param name="builderContext"></param>
        protected virtual void BuildExpressionQuery(ExpressionChain expressions, BuilderContext builderContext)
        {
            var previousExpression = ExpressionDispatcher.CreateTableExpression(expressions.Expressions[0], builderContext);

            previousExpression = BuildExpressionQuery(expressions, previousExpression, builderContext);
            BuildOffsetsAndLimits(builderContext);
            // then prepare Parts for SQL translation
            PrepareSqlOperands(builderContext);
            // now, we optimize anything we can
            OptimizeQuery(builderContext);
            // finally, compile our object creation method
            CompileRowCreator(builderContext);
            // in the very end, we keep the SELECT clause
            builderContext.ExpressionQuery.Select = builderContext.CurrentSelect;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns a Delegate to create a row for a given IDataRecord
        /// The Delegate is Func&lt;IDataRecord,MappingContext,"tableType">
        /// </summary>
        /// <param name="tableType">The table type (must be managed by DataContext)</param>
        /// <param name="parameters"></param>
        /// <param name="queryContext"></param>
        /// <returns></returns>
        public virtual Delegate GetTableReader(Type tableType, IList <string> parameters, QueryContext queryContext)
        {
            Delegate reader = null;

            if (queryContext.DataContext.QueryCacheEnabled)
            {
                reader = GetFromTableReaderCache(tableType, parameters);
            }
            if (reader == null)
            {
                var lambda = ExpressionDispatcher.BuildTableReader(tableType, parameters,
                                                                   new BuilderContext(queryContext));
                reader = lambda.Compile();
                if (queryContext.DataContext.QueryCacheEnabled)
                {
                    SetInTableReaderCache(tableType, parameters, reader);
                }
            }
            return(reader);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Builds the ExpressionQuery main Expression, given a Table (or projection) expression
 /// </summary>
 /// <param name="expressions"></param>
 /// <param name="tableExpression"></param>
 /// <param name="builderContext"></param>
 /// <returns></returns>
 protected Expression BuildExpressionQuery(ExpressionChain expressions, Expression tableExpression, BuilderContext builderContext)
 {
     tableExpression = ExpressionDispatcher.Analyze(expressions, tableExpression, builderContext);
     ExpressionDispatcher.BuildSelect(tableExpression, builderContext);
     return(tableExpression);
 }