Beispiel #1
0
        public void Combine(CamlGroupBy groupBy)
        {
            if (groupBy != null)
            {
                var fieldRefs = new List <CamlFieldRef>();
                if (FieldRefs != null)
                {
                    fieldRefs.AddRange(FieldRefs);
                }
                if (groupBy.Limit != null)
                {
                    Limit = Limit == null ? groupBy.Limit.Value : Math.Max(Limit.Value, groupBy.Limit.Value);
                }
                if (groupBy.Collapse != null)
                {
                    Collapse = Collapse == null ? groupBy.Collapse.Value : Collapse.Value | groupBy.Collapse.Value;
                }

                if (groupBy.FieldRefs != null)
                {
                    fieldRefs.AddRange(groupBy.FieldRefs);
                }
                this.FieldRefs = fieldRefs.ToArray();
            }
        }
Beispiel #2
0
        public static CamlGroupBy Combine(CamlGroupBy firstGroupBy, CamlGroupBy secondGroupBy)
        {
            CamlGroupBy groupBy   = null;
            bool        collapse  = false;
            int?        limit     = null;
            var         fieldRefs = new List <CamlFieldRef>();

            if (firstGroupBy != null && firstGroupBy.FieldRefs != null)
            {
                if (firstGroupBy.Limit != null)
                {
                    limit = firstGroupBy.Limit;
                }
                if (firstGroupBy.Collapse != null)
                {
                    collapse = firstGroupBy.Collapse.Value;
                }
                fieldRefs.AddRange(firstGroupBy.FieldRefs);
            }
            if (secondGroupBy != null && secondGroupBy.FieldRefs != null)
            {
                if (secondGroupBy.Limit != null)
                {
                    limit = limit != null?Math.Max(secondGroupBy.Limit.Value, limit.Value) : secondGroupBy.Limit;
                }
                if (secondGroupBy.Collapse != null)
                {
                    collapse = collapse | secondGroupBy.Collapse.Value;
                }
                fieldRefs.AddRange(secondGroupBy.FieldRefs);
            }
            if (fieldRefs.Count > 0)
            {
                groupBy = new CamlGroupBy(fieldRefs, collapse, limit);
            }
            return(groupBy);
        }