Пример #1
0
        public void Clone()
        {
            var clone = _orderByClause.Clone(_cloneContext);

            Assert.That(clone, Is.Not.Null);
            Assert.That(clone, Is.Not.SameAs(_orderByClause));
        }
Пример #2
0
        public void TestCloneOrderByClause()
        {
            OrderByClause orderByClause = new OrderByClause()
            {
                OrderExpressions = new List <OrderBy.OrderElement>()
                {
                    new OrderExpression()
                    {
                        Ascending  = true,
                        Expression = new ColumnReference()
                        {
                            Identifiers = new List <string>()
                            {
                                "c1"
                            }
                        }
                    }
                }
            };

            var clone = orderByClause.Clone() as OrderByClause;

            Assert.AreEqual(orderByClause, clone);
            Assert.IsFalse(ReferenceEquals(orderByClause, clone));
            Assert.IsFalse(ReferenceEquals(orderByClause.OrderExpressions, clone.OrderExpressions));

            for (int i = 0; i < orderByClause.OrderExpressions.Count; i++)
            {
                Assert.IsFalse(ReferenceEquals(orderByClause.OrderExpressions[i], clone.OrderExpressions[i]));
            }
        }
Пример #3
0
        public void Clone()
        {
            var clause = new OrderByClause("field1 desc, field2");
            var clone  = clause.Clone();

            Assert.AreEqual("field1 desc,field2", clone.ToString());
            Assert.AreEqual(clause, clone);
            clone.Reverse();
            Assert.AreNotEqual(clause, clone);
            clone.Reverse();
            Assert.AreEqual(clause, clone);
        }
Пример #4
0
 public override SqlNode Clone()
 {
     return(new SelectStatement()
     {
         Distinct = Distinct,
         FromClause = FromClause?.Clone() as FromClause,
         GroupByClause = GroupByClause?.Clone() as GroupByClause,
         HavingClause = HavingClause?.Clone() as HavingClause,
         OffsetLimitClause = OffsetLimitClause?.Clone() as OffsetLimitClause,
         OrderByClause = OrderByClause?.Clone() as OrderByClause,
         SelectElements = SelectElements?.Select(x => x.Clone() as SelectExpression).ToList(),
         WhereClause = WhereClause?.Clone() as WhereClause
     });
 }
Пример #5
0
        // ------------------------------------------
        // ACCESSORS
        // ------------------------------------------

        #region Accessors

        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns>Returns the cloned instance.</returns>
        public override object Clone(params string[] areas)
        {
            var clone = base.Clone(areas) as DbSingleQuery;

            clone.Fields           = Fields?.Select(p => p.Clone <DbField>()).ToList();
            clone.UnionClauses     = UnionClauses?.Select(p => p?.Clone <DbQueryUnionClause>()).ToList();
            clone.FromClause       = FromClause?.Clone <DbQueryFromClause>();
            clone.WhereClause      = WhereClause?.Clone <DbQueryWhereClause>();
            clone.GroupByClause    = GroupByClause?.Clone <DbQueryGroupByClause>();
            clone.HavingClause     = HavingClause?.Clone <DbQueryHavingClause>();
            clone.OrderByClause    = OrderByClause?.Clone <DbQueryOrderByClause>();
            clone.ReturnedIdFields = ReturnedIdFields?.Select(p => p.Clone <DbField>()).ToList();

            return(clone);
        }