/// <summary> /// Merges two <see cref="EntitySetAggregateToken"/> that have the same entity set into one. /// If the parameters do not share the the entity set, an exception is thrown. /// </summary> /// <param name="token1">First token that is going to be merged.</param> /// <param name="token2">Second token that is going to be merged.</param> /// <returns> /// Returns a token with the same entitySet as the parameters and with expressions from both objects. /// </returns> public static EntitySetAggregateToken Merge(EntitySetAggregateToken token1, EntitySetAggregateToken token2) { if (token1 == null) { return(token2); } if (token2 == null) { return(token1); } ExceptionUtils.Equals(token1.entitySet, token2.entitySet); return(new EntitySetAggregateToken(token1.entitySet, token1.expressions.Concat(token2.expressions))); }