Browse Source

Remove GetSingleBySpec

main
Eric Fleming 7 years ago
parent
commit
1152f4a45d
  1. 2
      src/ApplicationCore/Interfaces/IRepository.cs
  2. 11
      src/Infrastructure/Data/EfRepository.cs

2
src/ApplicationCore/Interfaces/IRepository.cs

@ -5,6 +5,6 @@ namespace Microsoft.eShopWeb.ApplicationCore.Interfaces
{ {
public interface IRepository<T> where T : BaseEntity public interface IRepository<T> where T : BaseEntity
{ {
T GetSingleBySpec(ISpecification<T> spec);
} }
} }

11
src/Infrastructure/Data/EfRepository.cs

@ -20,12 +20,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data
{ {
_dbContext = dbContext; _dbContext = dbContext;
} }
public T GetSingleBySpec(ISpecification<T> spec)
{
return List(spec).FirstOrDefault();
}
public virtual async Task<T> GetByIdAsync(int id) public virtual async Task<T> GetByIdAsync(int id)
{ {
return await _dbContext.Set<T>().FindAsync(id); return await _dbContext.Set<T>().FindAsync(id);
@ -36,10 +31,6 @@ namespace Microsoft.eShopWeb.Infrastructure.Data
return await _dbContext.Set<T>().ToListAsync(); return await _dbContext.Set<T>().ToListAsync();
} }
public IEnumerable<T> List(ISpecification<T> spec)
{
return ApplySpecification(spec).AsEnumerable();
}
public async Task<IReadOnlyList<T>> ListAsync(ISpecification<T> spec) public async Task<IReadOnlyList<T>> ListAsync(ISpecification<T> spec)
{ {
return await ApplySpecification(spec).ToListAsync(); return await ApplySpecification(spec).ToListAsync();

Loading…
Cancel
Save