Example #1
0
 /// <summary>
 /// 倒序
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="TResult"></typeparam>
 /// <param name="obj"></param>
 /// <param name="predicate"></param>
 /// <returns></returns>
 public static IQuery <T> ThenByDescending <T, TResult>(this IQuery <T> obj, Expression <Func <T, TResult> > predicate)
 {
     if (string.IsNullOrWhiteSpace(obj.OrderBy))
     {
         throw new Exception("请先调用OrderBy");
     }
     obj.OrderBy = $"{obj.OrderBy},{QueryableBuilder.GetPropertyName(predicate)} DESC";
     return(obj);
 }
Example #2
0
 /// <summary>
 /// 倒序
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="TResult"></typeparam>
 /// <param name="obj"></param>
 /// <param name="predicate"></param>
 /// <returns></returns>
 public static IQuery <T> OrderByDescending <T, TResult>(this IQuery <T> obj, Expression <Func <T, TResult> > predicate)
 {
     obj.OrderBy = $"ORDER BY {QueryableBuilder.GetPropertyName(predicate)} DESC";
     return(obj);
 }
 /// <summary>
 /// 顺序
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="TResult"></typeparam>
 /// <param name="obj"></param>
 /// <param name="predicate"></param>
 /// <returns></returns>
 public static IOrderQuery <T> ThenBy <T, TResult>(this IOrderQuery <T> obj, Expression <Func <T, TResult> > predicate)
 {
     obj.OrderBy = $"{obj.OrderBy},{QueryableBuilder.GetPropertyName(predicate)} ASC";
     return(obj);
 }