Skip to content

Commit

Permalink
use primary constructor in ProductRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
samanazadi1996 committed Jun 12, 2024
1 parent 960ead9 commit c76baff
Showing 1 changed file with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,16 @@
using CleanArchitecture.Domain.Products.Dtos;
using CleanArchitecture.Domain.Products.Entities;
using CleanArchitecture.Infrastructure.Persistence.Contexts;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using System.Threading.Tasks;

namespace CleanArchitecture.Infrastructure.Persistence.Repositories;

public class ProductRepository : GenericRepository<Product>, IProductRepository
public class ProductRepository(ApplicationDbContext dbContext) : GenericRepository<Product>(dbContext), IProductRepository

Check warning on line 11 in Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Persistence/Repositories/ProductRepository.cs

View workflow job for this annotation

GitHub Actions / build

Parameter 'ApplicationDbContext dbContext' is captured into the state of the enclosing type and its value is also passed to the base constructor. The value might be captured by the base class as well.

Check warning on line 11 in Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Persistence/Repositories/ProductRepository.cs

View workflow job for this annotation

GitHub Actions / build

Parameter 'ApplicationDbContext dbContext' is captured into the state of the enclosing type and its value is also passed to the base constructor. The value might be captured by the base class as well.
{
private readonly DbSet<Product> products;

public ProductRepository(ApplicationDbContext dbContext) : base(dbContext)
{
products = dbContext.Set<Product>();

}

public async Task<PagenationResponseDto<ProductDto>> GetPagedListAsync(int pageNumber, int pageSize, string name)
{
var query = products.OrderBy(p => p.Created).AsQueryable();
var query = dbContext.Products.OrderBy(p => p.Created).AsQueryable();

if (!string.IsNullOrEmpty(name))
{
Expand Down

0 comments on commit c76baff

Please sign in to comment.