コード例 #1
0
        internal CoordinatorFactory Compile()
        {
            RecordStateFactory[] recordStateFactoryArray;
            if (this._recordStateScratchpads != null)
            {
                recordStateFactoryArray = new RecordStateFactory[this._recordStateScratchpads.Count];
                for (int index = 0; index < recordStateFactoryArray.Length; ++index)
                {
                    recordStateFactoryArray[index] = this._recordStateScratchpads[index].Compile();
                }
            }
            else
            {
                recordStateFactoryArray = new RecordStateFactory[0];
            }
            CoordinatorFactory[] coordinatorFactoryArray = new CoordinatorFactory[this._nestedCoordinatorScratchpads.Count];
            for (int index = 0; index < coordinatorFactoryArray.Length; ++index)
            {
                coordinatorFactoryArray[index] = this._nestedCoordinatorScratchpads[index].Compile();
            }
            Expression expression1 = new CoordinatorScratchpad.ReplacementExpressionVisitor((Dictionary <Expression, Expression>)null, this._inlineDelegates).Visit(this.Element);
            Expression expression2 = new CoordinatorScratchpad.ReplacementExpressionVisitor(this._expressionWithErrorHandlingMap, this._inlineDelegates).Visit(this.Element);

            return((CoordinatorFactory)Activator.CreateInstance(typeof(CoordinatorFactory <>).MakeGenericType(this._elementType), (object)this.Depth, (object)this.StateSlotNumber, (object)this.HasData, (object)this.SetKeys, (object)this.CheckKeys, (object)coordinatorFactoryArray, (object)expression1, (object)expression2, (object)this.InitializeCollection, (object)recordStateFactoryArray));
        }
コード例 #2
0
 internal RecordState(RecordStateFactory recordStateFactory, CoordinatorFactory coordinatorFactory)
 {
     RecordStateFactory = recordStateFactory;
     CoordinatorFactory = coordinatorFactory;
     CurrentColumnValues = new object[RecordStateFactory.ColumnCount];
     PendingColumnValues = new object[RecordStateFactory.ColumnCount];
 }
コード例 #3
0
ファイル: recordstate.cs プロジェクト: dotnet/ef6tools
 internal RecordState(RecordStateFactory recordStateFactory, CoordinatorFactory coordinatorFactory)
 {
     RecordStateFactory  = recordStateFactory;
     CoordinatorFactory  = coordinatorFactory;
     CurrentColumnValues = new object[RecordStateFactory.ColumnCount];
     PendingColumnValues = new object[RecordStateFactory.ColumnCount];
 }
コード例 #4
0
 internal RecordStateFactory Compile()
 {
     RecordStateFactory[] recordStateFactoryArray = new RecordStateFactory[this._nestedRecordStateScratchpads.Count];
     for (int index = 0; index < recordStateFactoryArray.Length; ++index)
     {
         recordStateFactoryArray[index] = this._nestedRecordStateScratchpads[index].Compile();
     }
     return((RecordStateFactory)Activator.CreateInstance(typeof(RecordStateFactory), (object)this.StateSlotNumber, (object)this.ColumnCount, (object)recordStateFactoryArray, (object)this.DataRecordInfo, (object)this.GatherData, (object)this.PropertyNames, (object)this.TypeUsages));
 }
コード例 #5
0
 internal RecordState(
     RecordStateFactory recordStateFactory,
     CoordinatorFactory coordinatorFactory)
 {
     this.RecordStateFactory  = recordStateFactory;
     this.CoordinatorFactory  = coordinatorFactory;
     this.CurrentColumnValues = new object[this.RecordStateFactory.ColumnCount];
     this.PendingColumnValues = new object[this.RecordStateFactory.ColumnCount];
 }
コード例 #6
0
        protected CoordinatorFactory(
            int depth, int stateSlot, Func<Shaper, bool> hasData, Func<Shaper, bool> setKeys, Func<Shaper, bool> checkKeys,
            CoordinatorFactory[] nestedCoordinators, RecordStateFactory[] recordStateFactories)
        {
            Depth = depth;
            StateSlot = stateSlot;

            // figure out if there are any nested coordinators
            IsLeafResult = 0 == nestedCoordinators.Length;

            // if there is no explicit 'has data' discriminator, it means all rows contain data for the coordinator
            if (hasData == null)
            {
                HasData = _alwaysTrue;
            }
            else
            {
                HasData = hasData;
            }

            // if there is no explicit set key delegate, just return true (the value is not used anyways)
            if (setKeys == null)
            {
                SetKeys = _alwaysTrue;
            }
            else
            {
                SetKeys = setKeys;
            }

            // If there are no keys, it means different things depending on whether we are a leaf
            // coordinator or an inner (or 'driving') coordinator. For a leaf coordinator, it means
            // that every row is a new result. For an inner coordinator, it means that there is no
            // key to check. This should only occur where there is a SingleRowTable (in other words,
            // all rows are elements of a single child collection).
            if (checkKeys == null)
            {
                if (IsLeafResult)
                {
                    CheckKeys = _alwaysFalse; // every row is a new result (the keys don't match)
                }
                else
                {
                    CheckKeys = _alwaysTrue; // every row belongs to a single child collection
                }
            }
            else
            {
                CheckKeys = checkKeys;
            }
            NestedCoordinators = new ReadOnlyCollection<CoordinatorFactory>(nestedCoordinators);
            RecordStateFactories = new ReadOnlyCollection<RecordStateFactory>(recordStateFactories);

            // Determines whether this coordinator can be handled by a 'simple' enumerator. See IsSimple for details.
            IsSimple = IsLeafResult && null == checkKeys && null == hasData;
        }
コード例 #7
0
        // <summary>
        // Use the information stored on the scratchpad to compile an immutable factory used
        // to construct the coordinators used at runtime when materializing results.
        // </summary>
        internal CoordinatorFactory Compile()
        {
            RecordStateFactory[] recordStateFactories;
            if (null != _recordStateScratchpads)
            {
                recordStateFactories = new RecordStateFactory[_recordStateScratchpads.Count];
                for (var i = 0; i < recordStateFactories.Length; i++)
                {
                    recordStateFactories[i] = _recordStateScratchpads[i].Compile();
                }
            }
            else
            {
                recordStateFactories = new RecordStateFactory[0];
            }

            var nestedCoordinators = new CoordinatorFactory[_nestedCoordinatorScratchpads.Count];

            for (var i = 0; i < nestedCoordinators.Length; i++)
            {
                nestedCoordinators[i] = _nestedCoordinatorScratchpads[i].Compile();
            }

            // compile inline delegates
            var replacementVisitor = new ReplacementExpressionVisitor(null, _inlineDelegates);
            var element            = replacementVisitor.Visit(Element);

            // substitute expressions that have error handlers into a new expression (used
            // when a more detailed exception message is needed)
            replacementVisitor = new ReplacementExpressionVisitor(_expressionWithErrorHandlingMap, _inlineDelegates);
            var elementWithErrorHandling = replacementVisitor.Visit(Element);

            var result =
                (CoordinatorFactory)Activator.CreateInstance(
                    typeof(CoordinatorFactory <>).MakeGenericType(_elementType), new object[]
            {
                Depth,
                StateSlotNumber,
                HasData,
                SetKeys,
                CheckKeys,
                nestedCoordinators,
                element,
                elementWithErrorHandling,
                InitializeCollection,
                recordStateFactories
            });

            return(result);
        }
コード例 #8
0
        internal RecordStateFactory Compile()
        {
            var nestedRecordStateFactories = new RecordStateFactory[_nestedRecordStateScratchpads.Count];
            for (var i = 0; i < nestedRecordStateFactories.Length; i++)
            {
                nestedRecordStateFactories[i] = _nestedRecordStateScratchpads[i].Compile();
            }

            var result = (RecordStateFactory)Activator.CreateInstance(
                typeof(RecordStateFactory), new object[]
                    {
                        StateSlotNumber,
                        ColumnCount,
                        nestedRecordStateFactories,
                        DataRecordInfo,
                        GatherData,
                        PropertyNames,
                        TypeUsages
                    });
            return result;
        }
コード例 #9
0
        internal RecordStateFactory Compile()
        {
            var nestedRecordStateFactories = new RecordStateFactory[_nestedRecordStateScratchpads.Count];

            for (var i = 0; i < nestedRecordStateFactories.Length; i++)
            {
                nestedRecordStateFactories[i] = _nestedRecordStateScratchpads[i].Compile();
            }

            var result = (RecordStateFactory)Activator.CreateInstance(
                typeof(RecordStateFactory), new object[]
            {
                StateSlotNumber,
                ColumnCount,
                nestedRecordStateFactories,
                DataRecordInfo,
                GatherData,
                PropertyNames,
                TypeUsages
            });

            return(result);
        }
コード例 #10
0
        /// <summary>
        ///     Use the information stored on the scratchpad to compile an immutable factory used
        ///     to construct the coordinators used at runtime when materializing results.
        /// </summary>
        internal CoordinatorFactory Compile()
        {
            RecordStateFactory[] recordStateFactories;
            if (null != _recordStateScratchpads)
            {
                recordStateFactories = new RecordStateFactory[_recordStateScratchpads.Count];
                for (var i = 0; i < recordStateFactories.Length; i++)
                {
                    recordStateFactories[i] = _recordStateScratchpads[i].Compile();
                }
            }
            else
            {
                recordStateFactories = new RecordStateFactory[0];
            }

            var nestedCoordinators = new CoordinatorFactory[_nestedCoordinatorScratchpads.Count];
            for (var i = 0; i < nestedCoordinators.Length; i++)
            {
                nestedCoordinators[i] = _nestedCoordinatorScratchpads[i].Compile();
            }

            // compile inline delegates
            var replacementVisitor = new ReplacementExpressionVisitor(null, _inlineDelegates);
            var element = replacementVisitor.Visit(Element);

            // substitute expressions that have error handlers into a new expression (used
            // when a more detailed exception message is needed)
            replacementVisitor = new ReplacementExpressionVisitor(_expressionWithErrorHandlingMap, _inlineDelegates);
            var elementWithErrorHandling = replacementVisitor.Visit(Element);

            var result =
                (CoordinatorFactory)Activator.CreateInstance(
                    typeof(CoordinatorFactory<>).MakeGenericType(_elementType), new object[]
                        {
                            Depth,
                            StateSlotNumber,
                            HasData,
                            SetKeys,
                            CheckKeys,
                            nestedCoordinators,
                            element,
                            elementWithErrorHandling,
                            InitializeCollection,
                            recordStateFactories
                        });
            return result;
        }
コード例 #11
0
        public RecordStateFactory(
            int stateSlotNumber, int columnCount, RecordStateFactory[] nestedRecordStateFactories, DataRecordInfo dataRecordInfo,
            Expression<Func<Shaper, bool>> gatherData, string[] propertyNames, TypeUsage[] typeUsages, bool[] isColumnNested)
        {
            StateSlotNumber = stateSlotNumber;
            ColumnCount = columnCount;
            NestedRecordStateFactories = new ReadOnlyCollection<RecordStateFactory>(nestedRecordStateFactories);
            DataRecordInfo = dataRecordInfo;
            GatherData = gatherData.Compile();
            Description = gatherData.ToString();
            ColumnNames = new ReadOnlyCollection<string>(propertyNames);
            TypeUsages = new ReadOnlyCollection<TypeUsage>(typeUsages);

            FieldNameLookup = new FieldNameLookup(ColumnNames, -1);

            // pre-compute the nested objects from typeUsage, for performance
            if (isColumnNested == null)
            {
                isColumnNested = new bool[columnCount];

                for (var ordinal = 0; ordinal < columnCount; ordinal++)
                {
                    switch (typeUsages[ordinal].EdmType.BuiltInTypeKind)
                    {
                        case BuiltInTypeKind.EntityType:
                        case BuiltInTypeKind.ComplexType:
                        case BuiltInTypeKind.RowType:
                        case BuiltInTypeKind.CollectionType:
                            isColumnNested[ordinal] = true;
                            HasNestedColumns = true;
                            break;
                        default:
                            isColumnNested[ordinal] = false;
                            break;
                    }
                }
            }
            IsColumnNested = new ReadOnlyCollection<bool>(isColumnNested);
        }
コード例 #12
0
 public RecordStateFactory(
     int stateSlotNumber, int columnCount, RecordStateFactory[] nestedRecordStateFactories, DataRecordInfo dataRecordInfo,
     Expression gatherData, string[] propertyNames, TypeUsage[] typeUsages)
     : this(stateSlotNumber, columnCount, nestedRecordStateFactories, dataRecordInfo,
         CodeGenEmitter.BuildShaperLambda<bool>(gatherData), propertyNames, typeUsages, isColumnNested: null)
 {
 }