Ejemplo n.º 1
0
    /// <summary>
    /// Clones this item.
    /// </summary>
    /// <param name="cloneContext">The clones of all query source clauses are registered with this <see cref="CloneContext"/>.</param>
    /// <returns>A clone of this item.</returns>
    virtual public Ordering Clone (CloneContext cloneContext)
    {
      ArgumentUtility.CheckNotNull ("cloneContext", cloneContext);

      var clone = new Ordering (Expression, OrderingDirection);
      return clone;
    }
Ejemplo n.º 2
0
 public void SetUp ()
 {
   _resultOperatorNoDefault = new FirstResultOperator (false);
   _resultOperatorWithDefault = new FirstResultOperator (true);
   _querySourceMapping = new QuerySourceMapping ();
   _cloneContext = new CloneContext (_querySourceMapping);
 }
Ejemplo n.º 3
0
    /// <summary>
    /// Clones this clause.
    /// </summary>
    /// <param name="cloneContext">The clones of all query source clauses are registered with this <see cref="CloneContext"/>.</param>
    /// <returns>A clone of this clause.</returns>
    public SelectClause Clone (CloneContext cloneContext)
    {
      ArgumentUtility.CheckNotNull ("cloneContext", cloneContext);

      var result = new SelectClause (Selector);
      return result;
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Clones this clause, registering its clone with the <paramref name="cloneContext"/>.
    /// </summary>
    /// <param name="cloneContext">The clones of all query source clauses are registered with this <see cref="CloneContext"/>.</param>
    /// <returns>A clone of this clause.</returns>
    public virtual AdditionalFromClause Clone (CloneContext cloneContext)
    {
      ArgumentUtility.CheckNotNull ("cloneContext", cloneContext);

      var clone = new AdditionalFromClause (ItemName, ItemType, FromExpression);
      cloneContext.QuerySourceMapping.AddMapping (this, new QuerySourceReferenceExpression (clone));
      return clone;
    }
Ejemplo n.º 5
0
    public void Clone ()
    {
      var clonedClauseMapping = new QuerySourceMapping ();
      var cloneContext = new CloneContext (clonedClauseMapping);
      var clone = _resultOperator.Clone (cloneContext);

      Assert.That (clone, Is.InstanceOf (typeof (MinResultOperator)));
    }
    public void Clone ()
    {
      var clonedClauseMapping = new QuerySourceMapping ();
      var cloneContext = new CloneContext (clonedClauseMapping);
      var clone = _resultOperatorWithDefaultValue.Clone (cloneContext);

      Assert.That (clone, Is.InstanceOf (typeof (DefaultIfEmptyResultOperator)));
      Assert.That (((DefaultIfEmptyResultOperator) clone).OptionalDefaultValue, Is.SameAs (_resultOperatorWithDefaultValue.OptionalDefaultValue));
    }
    public void Clone ()
    {
      var clonedClauseMapping = new QuerySourceMapping ();
      var cloneContext = new CloneContext (clonedClauseMapping);
      var clone = _resultOperator.Clone (cloneContext);

      Assert.That (clone, Is.InstanceOf (typeof (ContainsResultOperator)));
      Assert.That (((ContainsResultOperator) clone).Item, Is.SameAs (_resultOperator.Item));
    }
    public void Clone ()
    {
      var clonedClauseMapping = new QuerySourceMapping ();
      var cloneContext = new CloneContext (clonedClauseMapping);
      var clone = _resultOperator.Clone (cloneContext);

      Assert.That (clone, Is.InstanceOf (typeof (ExceptResultOperator)));
      Assert.That (((ExceptResultOperator) clone).Source2, Is.SameAs (_source2));
    }
Ejemplo n.º 9
0
    /// <inheritdoc />
    public override ResultOperatorBase Clone (CloneContext cloneContext)
    {
      ArgumentUtility.CheckNotNull ("cloneContext", cloneContext);

      var clone = new FetchManyRequest (RelationMember);
      foreach (var innerFetchRequest in InnerFetchRequests)
        clone.GetOrAddInnerFetchRequest ((FetchRequestBase) innerFetchRequest.Clone (cloneContext));

      return clone;
    }
 public override ResultOperatorBase Clone(CloneContext cloneContext)
 {
     ArgumentUtility.CheckNotNull<CloneContext>("cloneContext", cloneContext);
     InnerFetchOneRequest fetchOneRequest = new InnerFetchOneRequest(base.RelationMember);
     foreach (FetchRequestBase current in base.InnerFetchRequests)
     {
         fetchOneRequest.GetOrAddInnerFetchRequest((FetchRequestBase)current.Clone(cloneContext));
     }
     return fetchOneRequest;
 }
Ejemplo n.º 11
0
    public void SetUp ()
    {
      _fromClause1 = ExpressionHelper.CreateMainFromClause_Int ("i", typeof (int), ExpressionHelper.CreateIntQueryable ());
      _fromClause2 = ExpressionHelper.CreateMainFromClause_Int ("j", typeof (int), ExpressionHelper.CreateIntQueryable ());

      _keySelector = ExpressionHelper.Resolve<int, int> (_fromClause2, j => j % 3);
      _elementSelector = ExpressionHelper.Resolve<int, string> (_fromClause1, i => i.ToString ());
      _resultOperator = new GroupResultOperator ("groupings", _keySelector, _elementSelector);

      _cloneContext = new CloneContext (new QuerySourceMapping ());
    }
Ejemplo n.º 12
0
    public void Clone ()
    {
      var clonedClauseMapping = new QuerySourceMapping ();
      var cloneContext = new CloneContext (clonedClauseMapping);
      var clone = _resultOperator.Clone (cloneContext);

      Assert.That (clone, Is.InstanceOf (typeof (ConcatResultOperator)));
      Assert.That (((ConcatResultOperator) clone).ItemName, Is.EqualTo ("itemName"));
      Assert.That (((ConcatResultOperator) clone).Source2, Is.SameAs (_source2));
      Assert.That (((ConcatResultOperator) clone).ItemType, Is.SameAs (typeof (int)));
    }
Ejemplo n.º 13
0
		public override AdditionalFromClause Clone(CloneContext cloneContext)
		{
			var joinClause = new NhJoinClause(ItemName, ItemType, FromExpression);
			foreach (var withClause in Restrictions)
			{
				var withClause2 = new NhWithClause(withClause.Predicate);
				joinClause.Restrictions.Add(withClause2);
			}

			cloneContext.QuerySourceMapping.AddMapping(this, new QuerySourceReferenceExpression(joinClause));
			return base.Clone(cloneContext);
		}
Ejemplo n.º 14
0
    /// <summary>
    /// Clones this clause.
    /// </summary>
    /// <param name="cloneContext">The clones of all query source clauses are registered with this <see cref="CloneContext"/>.</param>
    /// <returns>A clone of this clause.</returns>
    public OrderByClause Clone (CloneContext cloneContext)
    {
      ArgumentUtility.CheckNotNull ("cloneContext", cloneContext);

      var result = new OrderByClause();
      foreach (var ordering in Orderings)
      {
        var orderingClone = ordering.Clone (cloneContext);
        result.Orderings.Add (orderingClone);
      }

      return result;
    }
Ejemplo n.º 15
0
        /// <summary>
        /// Clones this clause, registering its clone with the <paramref name="cloneContext"/>.
        /// </summary>
        /// <param name="cloneContext">The clones of all query source clauses are registered with this <see cref="CloneContext"/>.</param>
        /// <returns>A clone of this clause.</returns>
        public JoinClause Clone(CloneContext cloneContext)
        {
            ArgumentUtility.CheckNotNull ("cloneContext", cloneContext);

              var clone = new JoinClause (ItemName, ItemType, InnerSequence, OuterKeySelector, InnerKeySelector);
              cloneContext.QuerySourceMapping.AddMapping (this, new QuerySourceReferenceExpression (clone));
              return clone;
        }
Ejemplo n.º 16
0
 public override ResultOperatorBase Clone(CloneContext cloneContext)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Make a clone of this object
 /// </summary>
 /// <param name="cloneContext"></param>
 /// <returns></returns>
 public override ResultOperatorBase Clone(Remotion.Linq.Clauses.CloneContext cloneContext)
 {
     return(new AsQueriableResultOperator());
 }
Ejemplo n.º 18
0
 public void SetUp ()
 {
   _additionalFromClause = ExpressionHelper.CreateAdditionalFromClause();
   _cloneContext = new CloneContext (new QuerySourceMapping ());      
 }
Ejemplo n.º 19
0
 public void SetUp ()
 {
   _joinClause = ExpressionHelper.CreateJoinClause<Cook> ();
   _cloneContext = new CloneContext (new QuerySourceMapping());
 }
 public override ResultOperatorBase Clone(CloneContext cloneContext)
 {
     return new FetchResultOperator(Selector);
 }
Ejemplo n.º 21
0
 IBodyClause IBodyClause.Clone(CloneContext cloneContext)
 {
     return(Clone(cloneContext));
 }
Ejemplo n.º 22
0
 /// <summary>
 ///     Clones this clause.
 /// </summary>
 /// <param name="cloneContext">The clones of all query source clauses are registered with this <see cref="CloneContext" />.</param>
 /// <returns></returns>
 public virtual NestClause Clone(CloneContext cloneContext)
 {
     var clone = new NestClause(ItemName, ItemType, InnerSequence, KeySelector, IsLeftOuterNest);
     return clone;
 }
 public override ResultOperatorBase Clone(CloneContext cloneContext)
 {
     return new IdFilterResultOperator(Parameter);
 }
            /// <summary>
            /// Given a query model, look at all the result operators for Concat operators, and split everything up
            /// into separate query models.
            /// </summary>
            /// <param name="queryModel"></param>
            /// <returns></returns>
            private static IEnumerable<QueryModel> SplitQMByConcatResultOperator(QueryModel queryModel)
            {
                // If there are no concat result operators in the list, then we just bail quickly.
                // This is to specifically avoid the Clone operation unless we actually need it.
                if (!queryModel.ResultOperators.Where(r => r is ConcatResultOperator).Any())
                {
                    return new QueryModel[] { queryModel };
                }

                // Now, look for concat operators in the list. Pop them out when we find them.
                ConcatResultOperator ro = null;
                var qm = queryModel.Clone();
                var lst = new List<QueryModel>();
                while ((ro = qm.ResultOperators.Reverse().Where(r => r is ConcatResultOperator).Cast<ConcatResultOperator>().FirstOrDefault()) != null)
                {
                    // We are going to make q QueryModel here that uses the second source in the Concat operator.
                    // This means everything that comes before this query can be ignored - and we want this "source" to
                    // become the query from clause. Note this also means messing with the "select" clause to make sure it
                    // isn't doing anything special (select clause comes before result operators, semantically).

                    QueryModel newQM = NewQMFromOldWithLifting(ro.Source2, qm.MainFromClause.ItemType, qm.MainFromClause.ItemName);

                    var cc = new CloneContext(new QuerySourceMapping());

                    var indexToRemoveTo = qm.ResultOperators.IndexOf(ro);
                    for (int i = indexToRemoveTo + 1; i < qm.ResultOperators.Count; i++)
                    {
                        newQM.ResultOperators.Add(qm.ResultOperators[i].Clone(cc));
                    }
                    lst.Add(newQM.Flatten());

                    // Ok - we've taken one branch. We need to remove it from the list of things to look at, and work on the
                    // next one.
                    qm.ResultOperators.Remove(ro);
                }

                // The QueryModel left over needs to be added to the list.
                lst.Add(qm.Flatten());
                return lst;
            }
 public override ResultOperatorBase Clone(CloneContext cloneContext)
 {
     return new WithExtensionArgResultOperator(_name, _value);
 }
Ejemplo n.º 26
0
 public void SetUp ()
 {
   _selector = Expression.Constant (new Cook ());
   _selectClause = new SelectClause (_selector);
   _cloneContext = new CloneContext (new QuerySourceMapping());
 }
Ejemplo n.º 27
0
    /// <summary>
    /// Clones this clause.
    /// </summary>
    /// <param name="cloneContext">The clones of all query source clauses are registered with this <see cref="CloneContext"/>.</param>
    /// <returns></returns>
    public virtual WhereClause Clone (CloneContext cloneContext)
    {
      ArgumentUtility.CheckNotNull ("cloneContext", cloneContext);

      var clone = new WhereClause (Predicate);
      return clone;
    }
Ejemplo n.º 28
0
 /// <summary>
 ///     Clones this clause.
 /// </summary>
 /// <param name="cloneContext">The clones of all query source clauses are registered with this <see cref="CloneContext" />.</param>
 /// <returns></returns>
 public virtual WhereMissingClause Clone(CloneContext cloneContext)
 {
     var clone = new WhereMissingClause(Predicate);
     return clone;
 }
 public override ResultOperatorBase Clone(CloneContext cloneContext)
 {
     return new DynamicMemberFilterResultOperator(FirstParameter);
 }
 public override ResultOperatorBase Clone(CloneContext cloneContext)
 {
     return new RevisionFilterResultOperator(FirstParameter);
 }
    public void Clone_WithoutResultSelector ()
    {
      var clonedClauseMapping = new QuerySourceMapping ();
      var cloneContext = new CloneContext (clonedClauseMapping);
      var clone = _resultOperatorWithoutResultSelector.Clone (cloneContext);

      Assert.That (clone, Is.InstanceOf (typeof (AggregateFromSeedResultOperator)));
      Assert.That (((AggregateFromSeedResultOperator) clone).Seed, Is.SameAs (_resultOperatorWithResultSelector.Seed));
      Assert.That (((AggregateFromSeedResultOperator) clone).Func, Is.SameAs (_resultOperatorWithResultSelector.Func));
      Assert.That (((AggregateFromSeedResultOperator) clone).OptionalResultSelector, Is.Null);
    }
Ejemplo n.º 32
0
 IBodyClause IBodyClause.Clone(CloneContext cloneContext)
 {
     return Clone(cloneContext);
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Clones this item, registering its clone with the <paramref name="cloneContext"/> if it is a query source clause.
 /// </summary>
 /// <param name="cloneContext">The clones of all query source clauses are registered with this <see cref="CloneContext"/>.</param>
 /// <returns>A clone of this item.</returns>
 public abstract ResultOperatorBase Clone(CloneContext cloneContext);