/// <summary> /// Para转ISugarQueryable /// </summary> /// <typeparam name="T"></typeparam> /// <param name="para"></param> /// <returns></returns> private ISugarQueryable <T> GetQueryByPara <T>(Para <T> para) where T : class, new() { if (!string.IsNullOrEmpty(para.SQL)) { return(_db.SqlQueryable <T>(para.SQL) .WhereIF(!string.IsNullOrEmpty(para.WhereSQL), para.WhereSQL) .WhereIF(para.Filter != null, para.Filter) .OrderByIF(!string.IsNullOrEmpty(para.OrderKey), para.OrderKey)); } else { return(_db.Queryable <T>() .WhereIF(!string.IsNullOrEmpty(para.WhereSQL), para.WhereSQL) .WhereIF(para.Filter != null, para.Filter) .OrderByIF(!string.IsNullOrEmpty(para.OrderKey), para.OrderKey)); } }
/// <summary> /// 根据Para(SQL WHERE LINQ)查询 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="para"></param> /// <returns></returns> public async Task <List <T> > QueryAsync <T>(Para <T> para) where T : class, new() { return(await GetQueryByPara <T>(para).ToListAsync()); }
/// <summary> /// 根据Para(SQL WHERE LINQ)查询 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="para"></param> /// <returns></returns> public List <T> Query <T>(Para <T> para) where T : class, new() { return(GetQueryByPara <T>(para).ToList()); }