mirror of https://github.com/abpframework/abp.git
2 changed files with 43 additions and 0 deletions
@ -0,0 +1,13 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
|
||||
|
namespace ProductManagement |
||||
|
{ |
||||
|
public interface IProductRepository : IBasicRepository<Product, Guid> |
||||
|
{ |
||||
|
Task<List<Product>> GetListAsync(string sorting, int maxResultCount, int skipCount); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using ProductManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using System.Linq; |
||||
|
using System.Linq.Dynamic.Core; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
|
||||
|
namespace ProductManagement |
||||
|
{ |
||||
|
public class EfCoreProductRepository : EfCoreRepository<IProductManagementDbContext, Product, Guid>, IProductRepository |
||||
|
{ |
||||
|
public EfCoreProductRepository(IDbContextProvider<IProductManagementDbContext> dbContextProvider) |
||||
|
: base(dbContextProvider) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public async Task<List<Product>> GetListAsync(string sorting, int maxResultCount, int skipCount) |
||||
|
{ |
||||
|
// TODO: refactor sorting
|
||||
|
var products = await DbSet.OrderBy(sorting ?? "creationTime desc") |
||||
|
.PageBy(skipCount, maxResultCount) |
||||
|
.ToListAsync(); |
||||
|
|
||||
|
return products; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue