/// <summary> /// 条件筛选 例如:expression 为 it=>it.a inValues值为 new string[]{"a" ,"b"} 生成的SQL就是 a in('a','b') /// </summary> /// <typeparam name="T"></typeparam> /// <param name="queryable"></param> /// <param name="expression"></param> /// <returns></returns> public static SqlSugar.Queryable <T> In <T, FieldType>(this SqlSugar.Queryable <T> queryable, Expression <Func <T, object> > expression, List <FieldType> inValues) { ResolveExpress re = new ResolveExpress(); var InFieldName = re.GetExpressionRightFiled(expression); return(In <T, FieldType>(queryable, InFieldName, inValues)); }
/// <summary> /// 获取最小值 /// </summary> /// <typeparam name="TResult"></typeparam> /// <typeparam name="T"></typeparam> /// <param name="queryable"></param> /// <param name="minField">列</param> /// <returns></returns> public static object Min <T>(this SqlSugar.Queryable <T> queryable, Expression <Func <T, object> > expression) { ResolveExpress re = new ResolveExpress(); var minField = re.GetExpressionRightFiled(expression); return(Min <T, object>(queryable, minField)); }
/// <summary> /// 分组 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="queryable"></param> /// <param name="groupFileds">如:id,name </param> /// <returns></returns> public static SqlSugar.Queryable <T> GroupBy <T>(this SqlSugar.Queryable <T> queryable, Expression <Func <T, object> > expression) { ResolveExpress re = new ResolveExpress(); var field = re.GetExpressionRightFiled(expression); var pre = queryable.GroupBy.IsValuable() ? "," : ""; queryable.GroupBy += pre + field; return(queryable); }
/// <summary> /// 排序 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="queryable"></param> /// <param name="orderFileds">如:id asc,name desc </param> /// <returns></returns> public static SqlSugar.Queryable <T> OrderBy <T>(this SqlSugar.Queryable <T> queryable, Expression <Func <T, object> > expression, OrderByType type = OrderByType.asc) { ResolveExpress re = new ResolveExpress(); var field = re.GetExpressionRightFiled(expression); var pre = queryable.OrderBy.IsValuable() ? "," : ""; queryable.OrderBy += pre + field + " " + type.ToString().ToUpper(); return(queryable); }