| | |
| | | return model.FirstOrDefault(); |
| | | } |
| | | |
| | | public SqlSugar.ISugarQueryable<T> GetAllAsync() |
| | | public SqlSugar.ISugarQueryable<T> GetAll() |
| | | { |
| | | var data =_db.Queryable<T>().Where(m=>m.IsDel =="0"); |
| | | return data; |
| | | } |
| | | public SqlSugar.ISugarQueryable<T> GetAllWhereAsync(System.Linq.Expressions.Expression<Func<T, bool>> predicate) |
| | | public async Task<List<T>> GetAllAsync() |
| | | { |
| | | var data = GetAllAsync().Where(predicate); |
| | | return await _db.Queryable<T>().Where(m => m.IsDel == "0").ToListAsync(); |
| | | } |
| | | public SqlSugar.ISugarQueryable<T> GetAllWhere(System.Linq.Expressions.Expression<Func<T, bool>> predicate) |
| | | { |
| | | var data = GetAll().Where(predicate); |
| | | return data; |
| | | } |
| | | public SqlSugar.ISugarQueryable<T> GetAllByOrderAsync(System.Linq.Expressions.Expression<Func<T, bool>> predicate, bool asc = true) |
| | | public SqlSugar.ISugarQueryable<T> GetAllByOrder(System.Linq.Expressions.Expression<Func<T, bool>> predicate, bool asc = true) |
| | | { |
| | | var type = OrderByType.Asc; |
| | | if (!asc) |
| | | { |
| | | type = OrderByType.Desc; |
| | | } |
| | | var data = GetAllWhereAsync(predicate).OrderBy(m => m.CreateTime, type); |
| | | var data = GetAllWhere(predicate).OrderBy(m => m.CreateTime, type); |
| | | return data; |
| | | } |
| | | public SqlSugar.ISugarQueryable<T> GeTAllByPageAsync(System.Linq.Expressions.Expression<Func<T, bool>> predicate, int pageSize, int pageIndex,out int count ) |
| | | public SqlSugar.ISugarQueryable<T> GeTAllByPage(System.Linq.Expressions.Expression<Func<T, bool>> predicate, int pageSize, int pageIndex,out int count ) |
| | | { |
| | | var list = GetAllWhereAsync(predicate); |
| | | var list = GetAllWhere(predicate); |
| | | count = list.Count(); |
| | | var data = list.Skip(pageSize * (pageIndex - 1)).Take(pageSize); |
| | | return data; |
| | | } |
| | | |
| | | public SqlSugar.ISugarQueryable<T> GetAllByOrderPageAsync(System.Linq.Expressions.Expression<Func<T, bool>> predicate, int pageSize, int pageIndex, out int count , bool asc = true) |
| | | public SqlSugar.ISugarQueryable<T> GetAllByOrderPage(System.Linq.Expressions.Expression<Func<T, bool>> predicate, int pageSize, int pageIndex, out int count , bool asc = true) |
| | | { |
| | | var list = GetAllByOrderAsync(predicate, asc); |
| | | var list = GetAllByOrder(predicate, asc); |
| | | count = list.Count(); |
| | | var data = list.Skip(pageSize * (pageIndex-1)).Take(pageSize); |
| | | |