Пример #1
0
        /// <summary>
        /// 初始化一个<see cref="OrderByItem"/>类型的实例
        /// </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;
        }