Beispiel #1
0
        public Query(IExpression expression, Order[] orders, int skip, int take)
        {
            if ((object)expression == null)
                throw new ArgumentNullException("expression");

            if ((object)orders == null)
                throw new ArgumentNullException("orders");

            this.expression = expression;
            this.orders = orders;
            this.skip = skip;
            this.take = take;
        }
        public static string GetSortText(IDataSourceTagSpecific dataSourceTagSpecific, IUnitOfWorkContext unitOfWorkContext, IList<IDataParameter> commandParameters, Order[] orders)
        {
            string expressionText;
            List<string> sortNames;

            if ((object)dataSourceTagSpecific == null)
                throw new ArgumentNullException("dataSourceTagSpecific");

            if ((object)unitOfWorkContext == null)
                throw new ArgumentNullException("unitOfWorkContext");

            if ((object)commandParameters == null)
                throw new ArgumentNullException("commandParameters");

            if ((object)orders == null)
                throw new ArgumentNullException("orders");

            sortNames = new List<string>();

            if ((object)orders != null)
            {
                foreach (Order order in orders)
                {
                    if ((object)order.Facet == null)
                        continue;

                    sortNames.Add(string.Format("{0} {1}", dataSourceTagSpecific.GetAliasedColumnName("t0", order.Facet.Name), order.Ascending ? "ASC" : "DESC"));
                }
            }

            if (sortNames.Count <= 0)
                sortNames.Add("1");

            expressionText = string.Join(", ", sortNames.ToArray());

            return expressionText;
        }