File tree Expand file tree Collapse file tree
DDD/MASA.BuildingBlocks.DDD.Domain
Data/MASA.BuildingBlocks.Data.Uow Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- <Project Sdk =" Microsoft.NET.Sdk" >
1+ <Project Sdk =" Microsoft.NET.Sdk" >
22
33 <PropertyGroup >
44 <TargetFramework >net6.0</TargetFramework >
Original file line number Diff line number Diff line change 11namespace MASA . BuildingBlocks . DDD . Domain . Repositories ;
2- public abstract class RepositoryBase < TEntity > : IRepository < TEntity > , IUnitOfWork
3- where TEntity : class , IEntity
2+ public abstract class BaseRepository < TEntity > : IRepository < TEntity > , IUnitOfWork
3+ where TEntity : class , IAggregateRoot
44{
55 #region IRepository<TEntity>
66
@@ -102,6 +102,10 @@ public async Task<PaginatedList<TEntity>> GetPaginatedListAsync(Expression<Func<
102102
103103 public bool DisableRollbackOnFailure { get ; set ; }
104104
105+ public abstract DbTransaction Transaction { get ; }
106+
107+ public abstract IUnitOfWork UnitOfWork { get ; }
108+
105109 public abstract Task CommitAsync ( CancellationToken cancellationToken = default ) ;
106110
107111 public abstract ValueTask DisposeAsync ( ) ;
@@ -110,5 +114,7 @@ public async Task<PaginatedList<TEntity>> GetPaginatedListAsync(Expression<Func<
110114
111115 public abstract Task SaveChangesAsync ( CancellationToken cancellationToken = default ) ;
112116
117+ public abstract Task < DbTransaction > BeginTransaction ( CancellationToken cancellationToken = default ) ;
118+
113119 #endregion
114120}
Original file line number Diff line number Diff line change 11namespace MASA . BuildingBlocks . DDD . Domain . Repositories ;
2- public interface IRepository < TAggregateRoot >
3- where TAggregateRoot : class , IAggregateRoot
2+ public interface IRepository < TEntity >
3+ where TEntity : class , IAggregateRoot
44{
55 IUnitOfWork UnitOfWork { get ; }
66
Original file line number Diff line number Diff line change 11namespace MASA . BuildingBlocks . DDD . Domain . SeedWork ;
2+ /// <summary>
3+ /// Reference from https://docs.microsoft.com/zh-cn/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/enumeration-classes-over-enum-types
4+ /// </summary>
25public abstract class Enumeration : IComparable
36{
47 public string Name { get ; private set ; }
Original file line number Diff line number Diff line change 1+ namespace MASA . BuildingBlocks . DDD . Domain . Specifications ;
2+ public abstract class BaseSpecification < T > : ISpecification < T >
3+ {
4+ public BaseSpecification ( Expression < Func < T , bool > > whereExpression )
5+ {
6+ WhereExpression = whereExpression ;
7+ }
8+ public Expression < Func < T , bool > > WhereExpression { get ; }
9+
10+ public List < Expression < Func < T , object > > > Includes { get ; } =
11+ new List < Expression < Func < T , object > > > ( ) ;
12+
13+ public List < string > IncludeStrings { get ; } = new List < string > ( ) ;
14+
15+ public abstract bool IsSatisfiedBy ( T obj ) ;
16+
17+ protected virtual void AddInclude ( Expression < Func < T , object > > includeExpression )
18+ {
19+ Includes . Add ( includeExpression ) ;
20+ }
21+
22+ protected virtual void AddInclude ( string includeString )
23+ {
24+ IncludeStrings . Add ( includeString ) ;
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ namespace MASA . BuildingBlocks . DDD . Domain . Specifications ;
2+ /// <summary>
3+ /// Reference from
4+ /// https://docs.microsoft.com/zh-cn/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/infrastructure-persistence-layer-implementation-entity-framework-core
5+ /// https://martinfowler.com/apsupp/spec.pdf
6+ /// </summary>
7+ public interface ISpecification < T >
8+ {
9+ bool IsSatisfiedBy ( T obj ) ;
10+
11+ Expression < Func < T , bool > > WhereExpression { get ; }
12+
13+ List < Expression < Func < T , object > > > Includes { get ; }
14+
15+ List < string > IncludeStrings { get ; }
16+ }
Original file line number Diff line number Diff line change 66global using MASA . BuildingBlocks . Dispatcher . Remoting ;
77global using MASA . BuildingBlocks . ReadWriteSpliting . CQRS . Commands ;
88global using MASA . BuildingBlocks . ReadWriteSpliting . CQRS . Queries ;
9+ global using System . Data . Common ;
910global using System . Linq . Expressions ;
1011global using System . Reflection ;
Original file line number Diff line number Diff line change 11namespace MASA . BuildingBlocks . Data . Uow ;
22public interface ITransaction
33{
4- DbTransaction Transaction { get ; set ; }
4+ DbTransaction Transaction { get ; }
55}
You can’t perform that action at this time.
0 commit comments