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(); }
public static SelectStatement Visit(QueryModel queryModel, DatabaseMapper mapper, bool aliasTables) { var visitor = new StatementCreator(mapper, aliasTables); queryModel.Accept(visitor); return(visitor.SelectStatement); }
public static FetchQueryModelBuilder[] RemoveFetchRequestsFromQueryModel (QueryModel queryModel) { ArgumentUtility.CheckNotNull ("queryModel", queryModel); var visitor = new FetchFilteringQueryModelVisitor (); queryModel.Accept (visitor); return visitor.FetchQueryModelBuilders.ToArray(); }
public static FetchQueryModelBuilder[] RemoveFetchRequestsFromQueryModel(QueryModel queryModel) { ArgumentUtility.CheckNotNull("queryModel", queryModel); var visitor = new FetchFilteringQueryModelVisitor(); queryModel.Accept(visitor); return(visitor.FetchQueryModelBuilders.ToArray()); }
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>()); }
public void Build(QueryModel queryModel) { queryModel.Accept(this); if (context.Settings.EnableMultipleEntities) { CreateQueryFilterForKeyFields(); } }
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(); }
/// <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); }
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>()); }
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(); }
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()); }
/// <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)); }
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)); }
public static void TransformQueryModel(QueryModel queryModel) { var instance = new QueryModelTransformer(); queryModel.Accept(instance); }
public void Build(QueryModel queryModel) { queryModel.Accept(this); CreateQueryFilterForKeyFields(); }
public void Build(QueryModel queryModel) { queryModel.Accept(this); }
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(); }