Ejemplo n.º 1
0
        /// <summary>
        /// 初始化排序项
        /// </summary>
        /// <param name="order">排序列</param>
        /// <param name="desc">是否倒排</param>
        /// <param name="type">实体类型</param>
        /// <param name="raw">使用原始值</param>
        /// <param name="prefix">前缀</param>
        public OrderByItem(string order, bool desc = false, Type type = null, bool raw = false, string prefix = null)
        {
            Order = order.SafeString();
            Desc  = desc;
            Type  = type;
            Raw   = raw;
            if (raw)
            {
                return;
            }
            Order = Order.RemoveEnd("asc");
            if (Order.ToLower().EndsWith("desc"))
            {
                Desc  = true;
                Order = Order.RemoveEnd("desc");
            }
            var item = new NameItem(Order);

            Column = item.Name;
            Prefix = string.IsNullOrWhiteSpace(item.Prefix) ? prefix : item.Prefix;
        }