|
@@ -150,6 +150,30 @@ namespace Hotline.Repository.SqlSugar
|
|
|
return (total.Value, items);
|
|
|
}
|
|
|
|
|
|
+ public async Task<List<TEntity>> QueryExtAsync(
|
|
|
+ Expression<Func<TEntity, bool>> predicate,
|
|
|
+ Func<ISugarQueryable<TEntity>, ISugarQueryable<TEntity>>? includes = null,
|
|
|
+ Func<ISugarQueryable<TEntity>, ISugarQueryable<TEntity>>? orderByCreator = null,
|
|
|
+ params (bool isWhere, Expression<Func<TEntity, bool>> expression)[] whereIfs)
|
|
|
+ {
|
|
|
+ var query = Db.Queryable<TEntity>().Where(predicate);
|
|
|
+ if (includes is not null)
|
|
|
+ query = includes(query);
|
|
|
+
|
|
|
+ if(whereIfs.Any())
|
|
|
+ {
|
|
|
+ foreach (var whereIf in whereIfs)
|
|
|
+ {
|
|
|
+ query = query.WhereIF(whereIf.isWhere, whereIf.expression);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (orderByCreator is not null)
|
|
|
+ query = orderByCreator(query);
|
|
|
+
|
|
|
+ return await query.ToListAsync();
|
|
|
+ }
|
|
|
+
|
|
|
public async Task<List<TEntity>> QueryExtAsync(Expression<Func<TEntity, bool>> predicate, Func<ISugarQueryable<TEntity>, ISugarQueryable<TEntity>> includes)
|
|
|
{
|
|
|
var query = Db.Queryable<TEntity>().Where(predicate);
|