protected override ResultOperatorBase CreateResultOperator(ClauseGenerationContext clauseGenerationContext)
        {
            var resultOperator = new FetchOneRequest(RelationMember);

            clauseGenerationContext.AddContextInfo(this, resultOperator);
            return(resultOperator);
        }
        private FetchRequestBase AddFetchRequest(QueryModel queryModel)
        {
            var relationMember = NormalizingMemberInfoFromExpressionUtility.GetProperty((Order o) => o.OrderTicket);
            var fetchRequest   = new FetchOneRequest(relationMember);

            queryModel.ResultOperators.Add(fetchRequest);
            return(fetchRequest);
        }
Exemple #3
0
        public void Apply_WithExistingFetchOneRequest()
        {
            var request = new FetchOneRequest(_node.RelationMember);

            QueryModel.ResultOperators.Add(request);

            _node.Apply(QueryModel, ClauseGenerationContext);

            Assert.That(QueryModel.ResultOperators.Count, Is.EqualTo(1));
            Assert.That(QueryModel.ResultOperators[0], Is.SameAs(request));
            Assert.That(ClauseGenerationContext.GetContextInfo(_node), Is.SameAs(QueryModel.ResultOperators[0]));
        }
    protected override QueryModel ApplyNodeSpecificSemantics (QueryModel queryModel, ClauseGenerationContext clauseGenerationContext)
    {
      var previousFetchRequest = clauseGenerationContext.GetContextInfo (Source) as FetchRequestBase;
      if (previousFetchRequest == null)
        throw new ParserException ("ThenFetchOne must directly follow another Fetch request.");

      FetchRequestBase innerFetchRequest = new FetchOneRequest (RelationMember);
      innerFetchRequest = previousFetchRequest.GetOrAddInnerFetchRequest (innerFetchRequest);
      clauseGenerationContext.AddContextInfo (this, innerFetchRequest);

      return queryModel;
    }
        public void Clone_WithInnerFetchRequests()
        {
            var innerRequest = new FetchOneRequest(_substitutionMember);

            _substitutionFetchRequest.GetOrAddInnerFetchRequest(innerRequest);

            var clone       = _substitutionFetchRequest.Clone(new CloneContext(new QuerySourceMapping()));
            var innerClones = ((FetchOneRequest)clone).InnerFetchRequests.ToArray();

            Assert.That(innerClones.Length, Is.EqualTo(1));
            Assert.That(innerClones[0], Is.InstanceOf(typeof(FetchOneRequest)));
            Assert.That(innerClones[0], Is.Not.SameAs(innerRequest));
            Assert.That(innerClones[0].RelationMember, Is.SameAs(innerRequest.RelationMember));
        }
        protected override QueryModel ApplyNodeSpecificSemantics(QueryModel queryModel, ClauseGenerationContext clauseGenerationContext)
        {
            var previousFetchRequest = clauseGenerationContext.GetContextInfo(Source) as FetchRequestBase;

            if (previousFetchRequest == null)
            {
                throw new ParserException("ThenFetchOne must directly follow another Fetch request.");
            }

            FetchRequestBase innerFetchRequest = new FetchOneRequest(RelationMember);

            innerFetchRequest = previousFetchRequest.GetOrAddInnerFetchRequest(innerFetchRequest);
            clauseGenerationContext.AddContextInfo(this, innerFetchRequest);

            return(queryModel);
        }
        public void SetUp()
        {
            _visitor    = new TestFetchFilteringQueryModelVisitor();
            _queryModel = ExpressionHelper.CreateQueryModel <Cook> ();

            _distinctResultOperator = new DistinctResultOperator();
            _countResultOperator    = new CountResultOperator();

            _fetchOneRequest  = new FetchOneRequest(typeof(Cook).GetProperty("Substitution"));
            _fetchManyRequest = new FetchManyRequest(typeof(Cook).GetProperty("Assistants"));

            _innerFetchManyRequest = new FetchManyRequest(typeof(Cook).GetProperty("Holidays"));
            _fetchOneRequest.GetOrAddInnerFetchRequest(_innerFetchManyRequest);

            _queryModel.ResultOperators.Add(_distinctResultOperator);
            _queryModel.ResultOperators.Add(_fetchOneRequest);
            _queryModel.ResultOperators.Add(_fetchManyRequest);
            _queryModel.ResultOperators.Add(_countResultOperator);
        }
 protected override ResultOperatorBase CreateResultOperator (ClauseGenerationContext clauseGenerationContext)
 {
   var resultOperator = new FetchOneRequest (RelationMember);
   clauseGenerationContext.AddContextInfo (this, resultOperator);
   return resultOperator;
 }
 public void SetUp()
 {
     _substitutionMember       = typeof(Cook).GetProperty("Substitution");
     _substitutionFetchRequest = new FetchOneRequest(_substitutionMember);
 }