Ejemplo n.º 1
0
        public void TestCloneGroupByClause()
        {
            GroupByClause groupByClause = new GroupByClause()
            {
                Groups = new List <GroupBy.Group>()
                {
                    new ExpressionGroup()
                    {
                        Expression = new ColumnReference()
                        {
                            Identifiers = new List <string>()
                            {
                                "c1"
                            }
                        }
                    }
                }
            };

            var clone = groupByClause.Clone() as GroupByClause;

            Assert.AreEqual(groupByClause, clone);
            Assert.IsFalse(ReferenceEquals(groupByClause, clone));
            Assert.IsFalse(ReferenceEquals(groupByClause.Groups, clone.Groups));

            for (int i = 0; i < groupByClause.Groups.Count; i++)
            {
                Assert.IsFalse(ReferenceEquals(groupByClause.Groups[i], clone.Groups[i]));
            }
        }
Ejemplo n.º 2
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
     });
 }
Ejemplo n.º 3
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);
        }