Browse Source

Microservicedemo: added product repository

pull/746/head
Yunus Emre Kalkan 7 years ago
parent
commit
d710108f77
  1. 13
      samples/MicroserviceDemo/modules/product/src/ProductManagement.Domain/ProductManagement/IProductRepository.cs
  2. 30
      samples/MicroserviceDemo/modules/product/src/ProductManagement.EntityFrameworkCore/ProductManagement/EfCoreProductRepository.cs

13
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<Product, Guid>
{
Task<List<Product>> GetListAsync(string sorting, int maxResultCount, int skipCount);
}
}

30
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<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…
Cancel
Save