Ejemplo n.º 1
0
        public QueryingEnumerable(
            CosmosQueryContext cosmosQueryContext,
            ISqlExpressionFactory sqlExpressionFactory,
            IQuerySqlGeneratorFactory querySqlGeneratorFactory,
            SelectExpression selectExpression,
            Func <CosmosQueryContext, JObject, T> shaper,
            Type contextType,
            string partitionKeyFromExtension,
            bool standAloneStateManager,
            bool threadSafetyChecksEnabled)
        {
            _cosmosQueryContext       = cosmosQueryContext;
            _sqlExpressionFactory     = sqlExpressionFactory;
            _querySqlGeneratorFactory = querySqlGeneratorFactory;
            _selectExpression         = selectExpression;
            _shaper                    = shaper;
            _contextType               = contextType;
            _queryLogger               = cosmosQueryContext.QueryLogger;
            _standAloneStateManager    = standAloneStateManager;
            _threadSafetyChecksEnabled = threadSafetyChecksEnabled;

            var partitionKey = selectExpression.GetPartitionKey(cosmosQueryContext.ParameterValues);

            if (partitionKey != null && partitionKeyFromExtension != null && partitionKeyFromExtension != partitionKey)
            {
                throw new InvalidOperationException(CosmosStrings.PartitionKeyMismatch(partitionKeyFromExtension, partitionKey));
            }

            _partitionKey = partitionKey ?? partitionKeyFromExtension;
        }
            public QueryingEnumerable(
                CosmosQueryContext cosmosQueryContext,
                ISqlExpressionFactory sqlExpressionFactory,
                IQuerySqlGeneratorFactory querySqlGeneratorFactory,
                SelectExpression selectExpression,
                Func <CosmosQueryContext, JObject, T> shaper,
                Type contextType,
                string partitionKeyFromExtension,
                bool performIdentityResolution)
            {
                _cosmosQueryContext       = cosmosQueryContext;
                _sqlExpressionFactory     = sqlExpressionFactory;
                _querySqlGeneratorFactory = querySqlGeneratorFactory;
                _selectExpression         = selectExpression;
                _shaper      = shaper;
                _contextType = contextType;
                _queryLogger = cosmosQueryContext.QueryLogger;
                _performIdentityResolution = performIdentityResolution;

                var partitionKey = selectExpression.GetPartitionKey(cosmosQueryContext.ParameterValues);

                if (partitionKey != null && partitionKeyFromExtension != null && partitionKeyFromExtension != partitionKey)
                {
                    throw new InvalidOperationException(CosmosStrings.PartitionKeyMismatch(partitionKeyFromExtension, partitionKey));
                }

                _partitionKey = partitionKey ?? partitionKeyFromExtension;
            }