コード例 #1
0
        public void VisitQueryModel()
        {
            var mainFromClauseMock = _mockRepository.StrictMock <MainFromClause> ("x", typeof(Cook), ExpressionHelper.CreateExpression());
            var selectClauseMock   = _mockRepository.StrictMock <SelectClause> (ExpressionHelper.CreateExpression());
            var queryModel         = new QueryModel(mainFromClauseMock, selectClauseMock);

            using (_mockRepository.Ordered())
            {
                _visitorMock
                .Expect(mock => mock.VisitQueryModel(queryModel))
                .CallOriginalMethod(OriginalCallOptions.CreateExpectation);
                mainFromClauseMock.Expect(mock => mock.Accept(_visitorMock, queryModel));
                _visitorMock
                .Expect(mock => PrivateInvoke.InvokeNonPublicMethod(mock, "VisitBodyClauses", queryModel.BodyClauses, queryModel));
                selectClauseMock.Expect(mock => mock.Accept(_visitorMock, queryModel));
                _visitorMock
                .Expect(mock => PrivateInvoke.InvokeNonPublicMethod(mock, "VisitResultOperators", queryModel.ResultOperators, queryModel));
            }

            _mockRepository.ReplayAll();

            queryModel.Accept(_visitorMock);

            _mockRepository.VerifyAll();
        }
コード例 #2
0
        public static SelectStatement Visit(QueryModel queryModel, DatabaseMapper mapper, bool aliasTables)
        {
            var visitor = new StatementCreator(mapper, aliasTables);

            queryModel.Accept(visitor);
            return(visitor.SelectStatement);
        }
コード例 #3
0
    public static FetchQueryModelBuilder[] RemoveFetchRequestsFromQueryModel (QueryModel queryModel)
    {
      ArgumentUtility.CheckNotNull ("queryModel", queryModel);

      var visitor = new FetchFilteringQueryModelVisitor ();
      queryModel.Accept (visitor);
      return visitor.FetchQueryModelBuilders.ToArray();
    }
コード例 #4
0
        public static FetchQueryModelBuilder[] RemoveFetchRequestsFromQueryModel(QueryModel queryModel)
        {
            ArgumentUtility.CheckNotNull("queryModel", queryModel);

            var visitor = new FetchFilteringQueryModelVisitor();

            queryModel.Accept(visitor);
            return(visitor.FetchQueryModelBuilders.ToArray());
        }
コード例 #5
0
        public IEnumerable <T> ExecuteCollection <T>(QueryModel queryModel)
        {
            var queryBuilder = new QueryBuilder();

            queryModel.Accept(new QueryModelVisitor(metadataProvider, queryBuilder, null));
            var builtQuery = queryBuilder.Build();

            return(execute(builtQuery).Cast <T>());
        }
コード例 #6
0
        public void Build(QueryModel queryModel)
        {
            queryModel.Accept(this);

            if (context.Settings.EnableMultipleEntities)
            {
                CreateQueryFilterForKeyFields();
            }
        }
コード例 #7
0
ファイル: QueryModelTest.cs プロジェクト: zapov/Relinq
        public void Accept()
        {
            var repository  = new MockRepository();
            var visitorMock = repository.StrictMock <IQueryModelVisitor>();

            visitorMock.Expect(mock => mock.VisitQueryModel(_queryModel));

            repository.ReplayAll();

            _queryModel.Accept(visitorMock);

            repository.VerifyAll();
        }
コード例 #8
0
ファイル: ODataQueryExecutor.cs プロジェクト: keithlemon/Beef
        /// <summary>
        /// Gets the <see cref="ODataQueryAggregator"/> from the <see cref="QueryModel"/>.
        /// </summary>
        private ODataQueryAggregator GetQueryAggregator(QueryModel queryModel, int?pagingTakeOverride)
        {
            var visitor = new ODataQueryModelVisitor(QueryArgs);

            queryModel.Accept(visitor);

            var aggregator = visitor.GetQueryAggregator();

            if (pagingTakeOverride.HasValue)
            {
                aggregator.Paging.OverrideTake(pagingTakeOverride.Value);
            }

            return(aggregator);
        }
コード例 #9
0
        public IEnumerable <T> ExecuteCollection <T>(QueryModel queryModel)
        {
            BuiltQuery builtQuery;

            if (EntityHelpers.IsConstant(typeof(T)))
            {
                builtQuery = BuiltQuery.Constant(typeof(T));
            }
            else
            {
                var builder = new QueryBuilder(typeRegistry);
                queryModel.Accept(new QueryModelVisitor(builder));
                builtQuery = builder.Build();
            }
            return(execute(builtQuery).Cast <T>());
        }
コード例 #10
0
    public static SqlStatement TransformQueryModel (
        QueryModel queryModel,
        ISqlPreparationContext parentPreparationContext,
        ISqlPreparationStage stage,
        UniqueIdentifierGenerator generator,
        ResultOperatorHandlerRegistry resultOperatorHandlerRegistry)
    {
      ArgumentUtility.CheckNotNull ("queryModel", queryModel);
      ArgumentUtility.CheckNotNull ("stage", stage);
      ArgumentUtility.CheckNotNull ("generator", generator);
      ArgumentUtility.CheckNotNull ("resultOperatorHandlerRegistry", resultOperatorHandlerRegistry);

      var visitor = new SqlPreparationQueryModelVisitor (parentPreparationContext, stage, generator, resultOperatorHandlerRegistry);
      queryModel.Accept (visitor);

      return visitor.GetSqlStatement();
    }
コード例 #11
0
        public static SqlStatement TransformQueryModel(
            QueryModel queryModel,
            ISqlPreparationContext parentPreparationContext,
            ISqlPreparationStage stage,
            UniqueIdentifierGenerator generator,
            ResultOperatorHandlerRegistry resultOperatorHandlerRegistry)
        {
            ArgumentUtility.CheckNotNull("queryModel", queryModel);
            ArgumentUtility.CheckNotNull("stage", stage);
            ArgumentUtility.CheckNotNull("generator", generator);
            ArgumentUtility.CheckNotNull("resultOperatorHandlerRegistry", resultOperatorHandlerRegistry);

            var visitor = new SqlPreparationQueryModelVisitor(parentPreparationContext, stage, generator, resultOperatorHandlerRegistry);

            queryModel.Accept(visitor);

            return(visitor.GetSqlStatement());
        }
コード例 #12
0
        /// <summary>
        /// Builds the mongo-style query string to be run against the backend.
        /// </summary>
        /// <param name="query">LINQ-style query that can be used to filter delete results.</param>
        /// <param name="visitorClause">Enum to filter LINQ clauses which should be used in a query for network request.</param>
        /// <returns>The mongo-style query string.</returns>
        private static string GetQuery <T>(IQueryable <object> query, VisitorClause visitorClause)
        {
            if (query != null)
            {
                StringQueryBuilder queryBuilder = new StringQueryBuilder();

                KinveyQueryVisitor visitor    = new KinveyQueryVisitor(queryBuilder, typeof(T), visitorClause);
                QueryModel         queryModel = (query.Provider as KinveyQueryProvider)?.qm;

                queryBuilder.Write("{");
                queryModel?.Accept(visitor);
                queryBuilder.Write("}");

                string mongoQuery = queryBuilder.BuildQueryString();
                return(mongoQuery);
            }

            return(default(string));
        }
コード例 #13
0
ファイル: WssQueryExecutor.cs プロジェクト: mamift/WSS.XSD
        public IEnumerable <T> ExecuteCollection <T>(QueryModel queryModel)
        {
            var mapping = new QuerySourceMapping();

            queryModel.Accept(new WssCamlVisitor());

            var selectorExpr = queryModel.SelectClause.Selector;
            var fromExpr     = queryModel.MainFromClause.FromExpression;
            var bodyExprs    = queryModel.BodyClauses.OfType <WhereClause>().ToList();

            var fromItem       = queryModel.MainFromClause.ItemName;
            var fromSource     = fromExpr.ToReadableString();
            var selectorString = selectorExpr.ToReadableString();
            var bcStrings      = bodyExprs.Select(bc => bc.Predicate.ToReadableString());

            var syntaxTree = CSharpSyntaxTree.ParseText(fromSource);

            yield return(default(T));
        }
コード例 #14
0
        public static void TransformQueryModel(QueryModel queryModel)
        {
            var instance = new QueryModelTransformer();

            queryModel.Accept(instance);
        }
コード例 #15
0
        public void Build(QueryModel queryModel)
        {
            queryModel.Accept(this);

            CreateQueryFilterForKeyFields();
        }
コード例 #16
0
 public void Build(QueryModel queryModel)
 {
     queryModel.Accept(this);
 }
コード例 #17
0
    public void VisitQueryModel ()
    {
      var mainFromClauseMock = _mockRepository.StrictMock<MainFromClause> ("x", typeof (Cook), ExpressionHelper.CreateExpression());
      var selectClauseMock = _mockRepository.StrictMock<SelectClause> (ExpressionHelper.CreateExpression());
      var queryModel = new QueryModel (mainFromClauseMock, selectClauseMock);

      using (_mockRepository.Ordered())
      {
        _visitorMock
            .Expect (mock => mock.VisitQueryModel (queryModel))
            .CallOriginalMethod (OriginalCallOptions.CreateExpectation);
        mainFromClauseMock.Expect (mock => mock.Accept (_visitorMock, queryModel));
        _visitorMock
            .Expect (mock => PrivateInvoke.InvokeNonPublicMethod (mock, "VisitBodyClauses", queryModel.BodyClauses, queryModel));
        selectClauseMock.Expect (mock => mock.Accept (_visitorMock, queryModel));
        _visitorMock
            .Expect (mock => PrivateInvoke.InvokeNonPublicMethod (mock, "VisitResultOperators", queryModel.ResultOperators, queryModel));
      }

      _mockRepository.ReplayAll();

      queryModel.Accept (_visitorMock);

      _mockRepository.VerifyAll();
    }