File tree Expand file tree Collapse file tree 4 files changed +66
-0
lines changed Expand file tree Collapse file tree 4 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 44 <TargetFramework >netcoreapp3.1</TargetFramework >
55 </PropertyGroup >
66
7+ <ItemGroup >
8+ <ProjectReference Include =" ..\Domain\Domain.csproj" />
9+ </ItemGroup >
10+
711 <ItemGroup >
812 <Folder Include =" Interfaces\" />
913 </ItemGroup >
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . Linq . Expressions ;
5+ using System . Text ;
6+
7+ namespace Application
8+ {
9+ public interface IRepositoryBase < T >
10+ {
11+ IQueryable < T > FindAll ( ) ;
12+ IQueryable < T > FindByCondition ( Expression < Func < T , bool > > expression ) ;
13+ void Create ( T entity ) ;
14+ void Update ( T entity ) ;
15+ void Delete ( T entity ) ;
16+ }
17+ }
Original file line number Diff line number Diff line change 88 <Folder Include =" Repositories\" />
99 </ItemGroup >
1010
11+ <ItemGroup >
12+ <ProjectReference Include =" ..\Application\Application.csproj" />
13+ <ProjectReference Include =" ..\Infrastructure.Persistence\Infrastructure.Persistence.csproj" />
14+ </ItemGroup >
15+
1116</Project >
Original file line number Diff line number Diff line change 1+ using Application ;
2+ using Infrastructure . Persistence . Contexts ;
3+ using Microsoft . EntityFrameworkCore ;
4+ using System ;
5+ using System . Collections . Generic ;
6+ using System . Linq ;
7+ using System . Linq . Expressions ;
8+ using System . Text ;
9+
10+ namespace Infrastructure . Service
11+ {
12+ public abstract class RepositoryBase < T > : IRepositoryBase < T > where T : class
13+ {
14+ protected RepositoryContext RepositoryContext { get ; set ; }
15+ public RepositoryBase ( RepositoryContext repositoryContext )
16+ {
17+ this . RepositoryContext = repositoryContext ;
18+ }
19+ public IQueryable < T > FindAll ( )
20+ {
21+ return this . RepositoryContext . Set < T > ( ) . AsNoTracking ( ) ;
22+ }
23+ public IQueryable < T > FindByCondition ( Expression < Func < T , bool > > expression )
24+ {
25+ return this . RepositoryContext . Set < T > ( ) . Where ( expression ) . AsNoTracking ( ) ;
26+ }
27+ public void Create ( T entity )
28+ {
29+ this . RepositoryContext . Set < T > ( ) . Add ( entity ) ;
30+ }
31+ public void Update ( T entity )
32+ {
33+ this . RepositoryContext . Set < T > ( ) . Update ( entity ) ;
34+ }
35+ public void Delete ( T entity )
36+ {
37+ this . RepositoryContext . Set < T > ( ) . Remove ( entity ) ;
38+ }
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments