Exemplo n.º 1
0
        protected IOrderByClause Add(IOrderByItem item, AddWhen when)
        {
            int existingIndex = InnerList.FindIndex(existing =>
                                                    existing.Field == item.Field);

            if (existingIndex >= 0)
            {
                switch (when)
                {
                case AddWhen.MustBeMissing:
                    throw new ArgumentException(String.Format("The clause already contains a sort criteria for {0}",
                                                              item.Field));

                case AddWhen.WhenMissing:
                    return(this);

                case AddWhen.Always:
                    InnerList.RemoveAt(existingIndex);
                    break;
                }
            }


            item.Owner = this.Owner;

            InnerList.Add(item);
            Touch();
            return(this);
        }
Exemplo n.º 2
0
        protected IOrderByClause Add(IOrderByItem item, AddWhen when)
        {
            int existingIndex = InnerList.FindIndex(existing =>
                existing.Field == item.Field);

            if (existingIndex >= 0)
            {
                switch(when) {
                    case AddWhen.MustBeMissing:
                        throw new ArgumentException(String.Format("The clause already contains a sort criteria for {0}",
                            item.Field));
                    case AddWhen.WhenMissing:
                        return this;
                    case AddWhen.Always:
                        InnerList.RemoveAt(existingIndex);
                        break;
                }
            }

            item.Owner = this.Owner;

            InnerList.Add(item);
            Touch();
            return this;
        }