Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit edef0e8

Browse files
Infrastructure refactored
1 parent 8347eff commit edef0e8

File tree

6 files changed

+17
-11
lines changed

6 files changed

+17
-11
lines changed
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
42

53
namespace AspnetRun.Infrastructure.Exceptions
64
{
@@ -10,5 +8,10 @@ internal InfrastructureException(string businessMessage)
108
: base(businessMessage)
119
{
1210
}
11+
12+
internal InfrastructureException(string message, Exception innerException)
13+
: base(message, innerException)
14+
{
15+
}
1316
}
1417
}

‎src/AspnetRun.Infrastructure/Repository/AspnetRunRepository.cs renamed to ‎src/AspnetRun.Infrastructure/Repository/Base/Repository.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
using System.Linq.Expressions;
1010
using System.Threading.Tasks;
1111

12-
namespace AspnetRun.Infrastructure.Repository
12+
namespace AspnetRun.Infrastructure.Repository.Base
1313
{
14-
public class AspnetRunRepository<T> : IRepository<T> where T : Entity
14+
public class Repository<T> : IRepository<T> where T : Entity
1515
{
1616
protected readonly AspnetRunContext _dbContext;
1717

18-
public AspnetRunRepository(AspnetRunContext dbContext)
18+
public Repository(AspnetRunContext dbContext)
1919
{
2020
_dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
2121
}
@@ -49,7 +49,7 @@ public async Task<IReadOnlyList<T>> GetAsync(Expression<Func<T, bool>> predicate
4949
{
5050
IQueryable<T> query = _dbContext.Set<T>();
5151
if (disableTracking) query = query.AsNoTracking();
52-
52+
5353
if (!string.IsNullOrWhiteSpace(includeString)) query = query.Include(includeString);
5454

5555
if (predicate != null) query = query.Where(predicate);
@@ -95,6 +95,6 @@ public async Task DeleteAsync(T entity)
9595
{
9696
_dbContext.Set<T>().Remove(entity);
9797
await _dbContext.SaveChangesAsync();
98-
}
98+
}
9999
}
100100
}

‎src/AspnetRun.Infrastructure/Repository/SpecificationEvaluator.cs renamed to ‎src/AspnetRun.Infrastructure/Repository/Base/SpecificationEvaluator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Microsoft.EntityFrameworkCore;
55
using System.Linq;
66

7-
namespace AspnetRun.Infrastructure.Repository
7+
namespace AspnetRun.Infrastructure.Repository.Base
88
{
99
public class SpecificationEvaluator<T> where T : Entity
1010
{

‎src/AspnetRun.Infrastructure/Repository/CategoryRepository.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
using AspnetRun.Core.Repositories;
33
using AspnetRun.Core.Specifications;
44
using AspnetRun.Infrastructure.Data;
5+
using AspnetRun.Infrastructure.Repository.Base;
56
using System.Linq;
67
using System.Threading.Tasks;
78

89
namespace AspnetRun.Infrastructure.Repository
910
{
10-
public class CategoryRepository : AspnetRunRepository<Category>, ICategoryRepository
11+
public class CategoryRepository : Repository<Category>, ICategoryRepository
1112
{
1213
public CategoryRepository(AspnetRunContext dbContext) : base(dbContext)
1314
{

‎src/AspnetRun.Infrastructure/Repository/ProductRepository.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using AspnetRun.Core.Repositories;
33
using AspnetRun.Core.Specifications;
44
using AspnetRun.Infrastructure.Data;
5+
using AspnetRun.Infrastructure.Repository.Base;
56
using Microsoft.EntityFrameworkCore;
67
using System;
78
using System.Collections.Generic;
@@ -11,7 +12,7 @@
1112

1213
namespace AspnetRun.Infrastructure.Repository
1314
{
14-
public class ProductRepository : AspnetRunRepository<Product>, IProductRepository
15+
public class ProductRepository : Repository<Product>, IProductRepository
1516
{
1617
public ProductRepository(AspnetRunContext dbContext) : base(dbContext)
1718
{

‎src/AspnetRun.Web/Startup.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using AspnetRun.Core.Repositories;
2020
using AspnetRun.Core.Repositories.Base;
2121
using AspnetRun.Core.Configuration;
22+
using AspnetRun.Infrastructure.Repository.Base;
2223

2324
namespace AspnetRun.Web
2425
{
@@ -76,7 +77,7 @@ private void ConfigureAspnetRunServices(IServiceCollection services)
7677

7778
// Add Infrastructure Layer
7879
ConfigureDatabases(services);
79-
services.AddScoped(typeof(IRepository<>), typeof(AspnetRunRepository<>));
80+
services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
8081
services.AddScoped<IProductRepository, ProductRepository>();
8182
services.AddScoped<ICategoryRepository, CategoryRepository>();
8283
services.AddScoped(typeof(IAppLogger<>), typeof(LoggerAdapter<>));

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /