示例#1
0
        public DbSet <T> OrderBy <S>(OrderOpt opt, Expression <Func <T, S> > exp)
        {
            List <string> lstName = new List <string>();
            var           colmem  = exp.Body as MemberExpression;

            if (colmem != null)
            {
                lstName.Add(colmem.Member.Name);
            }
            else
            {
                var colmem2 = exp.Body as NewExpression;
                if (colmem2 != null)
                {
                    lstName.AddRange(colmem2.Members.Select(x => x.Name));
                }
            }
            if (lstName.Count < 1)
            {
                throw new ArgumentException("不支持的表达式");
            }


            return(this);
        }
示例#2
0
        public static string ToSql(this OrderOpt opt)
        {
            switch (opt)
            {
            case OrderOpt.ASC:
                return(" ASC");

            case OrderOpt.DESC:
                return(" DESC");

            default:
                throw new ArgumentException("未知的排序修饰符");
            }
        }
示例#3
0
 public OrderByNode(Column col, OrderOpt opt)
 {
     this.col = col;
     this.opt = opt;
 }