diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Domain/ProductManagement/IProductRepository.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Domain/ProductManagement/IProductRepository.cs new file mode 100644 index 0000000000..c6a1c865c1 --- /dev/null +++ b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Domain/ProductManagement/IProductRepository.cs @@ -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 + { + Task> GetListAsync(string sorting, int maxResultCount, int skipCount); + } +} diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.EntityFrameworkCore/ProductManagement/EfCoreProductRepository.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.EntityFrameworkCore/ProductManagement/EfCoreProductRepository.cs new file mode 100644 index 0000000000..c229505c36 --- /dev/null +++ b/samples/MicroserviceDemo/modules/product/src/ProductManagement.EntityFrameworkCore/ProductManagement/EfCoreProductRepository.cs @@ -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, IProductRepository + { + public EfCoreProductRepository(IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + } + + public async Task> GetListAsync(string sorting, int maxResultCount, int skipCount) + { + // TODO: refactor sorting + var products = await DbSet.OrderBy(sorting ?? "creationTime desc") + .PageBy(skipCount, maxResultCount) + .ToListAsync(); + + return products; + } + } +}