diff --git a/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj b/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj index a9bee21..073421d 100644 --- a/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj +++ b/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj @@ -4,7 +4,7 @@ netstandard2.1;net6.0;net7.0;net8.0 AnyCPU;x64;x86 EasyMicroservices - 0.0.1.47 + 0.0.1.48 asp core servces. EasyMicroservices@gmail.com core,cores,base,database,services,asp,aspnet diff --git a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj index 9e08e79..2f7d62c 100644 --- a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj +++ b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj @@ -4,7 +4,7 @@ net6.0;net7.0;net8.0 AnyCPU;x64;x86 EasyMicroservices - 0.0.1.47 + 0.0.1.48 asp core servces. EasyMicroservices@gmail.com core,cores,base,database,services,asp,aspnet,aspcore,efcore diff --git a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/UnitOfWork.cs b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/UnitOfWork.cs index 112fb98..c52e97d 100644 --- a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/UnitOfWork.cs +++ b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/UnitOfWork.cs @@ -109,6 +109,22 @@ public virtual IDatabase GetDatabase() } #region ContractLogic + LogicOptions? _defaultLogicOptions; + /// + /// + /// + public virtual void SetDefaultLogicOptions(LogicOptions logicOptions) + { + _defaultLogicOptions = logicOptions; + } + + LogicOptions GetLogicOptions(LogicOptions logicOptions) + { + if (_defaultLogicOptions.HasValue && logicOptions.UniqueIdentityStrategy == DataTypes.UniqueIdentityStrategy.Default) + return _defaultLogicOptions.Value; + return logicOptions; + } + /// /// /// @@ -117,7 +133,7 @@ public virtual IDatabase GetDatabase() public virtual IContractLogic GetLongLogic(LogicOptions logicOptions = default) where TEntity : class { - return GetInternalLongContractLogic(logicOptions); + return GetInternalLongContractLogic(GetLogicOptions(logicOptions)); } /// @@ -128,7 +144,7 @@ public virtual IContractLogic GetLongL /// public IContractLogic GetLogic(LogicOptions logicOptions = default) where TEntity : class { - return GetInternalContractLogic(logicOptions); + return GetInternalContractLogic(GetLogicOptions(logicOptions)); } /// @@ -141,7 +157,7 @@ public virtual IContractLogic Ge where TContract : class where TEntity : class { - return GetInternalLongContractLogic(logicOptions); + return GetInternalLongContractLogic(GetLogicOptions(logicOptions)); } /// @@ -152,7 +168,7 @@ public virtual IContractLogic Ge public virtual IContractLogic GetLongReadableLogic(LogicOptions logicOptions = default) where TEntity : class { - return GetInternalLongContractLogic(logicOptions); + return GetInternalLongContractLogic(GetLogicOptions(logicOptions)); } /// @@ -165,7 +181,7 @@ public virtual IContractLogic Ge where TContract : class where TEntity : class { - return GetInternalLongContractLogic(logicOptions); + return GetInternalLongContractLogic(GetLogicOptions(logicOptions)); } /// @@ -177,7 +193,7 @@ public virtual IContractLogic Ge public virtual IContractLogic GetLogic(LogicOptions logicOptions = default) where TEntity : class { - return AddDisposable(new IdSchemaDatabaseMappedLogicBase(GetDatabase().GetReadableOf(), GetDatabase().GetWritableOf(), this, logicOptions)); + return AddDisposable(new IdSchemaDatabaseMappedLogicBase(GetDatabase().GetReadableOf(), GetDatabase().GetWritableOf(), this, GetLogicOptions(logicOptions))); } /// @@ -191,7 +207,7 @@ public virtual IContractLogic Get where TContract : class where TEntity : class { - return AddDisposable(new IdSchemaDatabaseMappedLogicBase(GetDatabase().GetReadableOf(), GetDatabase().GetWritableOf(), this, logicOptions)); + return AddDisposable(new IdSchemaDatabaseMappedLogicBase(GetDatabase().GetReadableOf(), GetDatabase().GetWritableOf(), this, GetLogicOptions(logicOptions))); } @@ -204,7 +220,7 @@ public virtual IContractLogic Get public virtual IContractLogic GetReadableLogic(LogicOptions logicOptions = default) where TEntity : class { - return AddDisposable(new IdSchemaDatabaseMappedLogicBase(GetDatabase().GetReadableOf(), this, logicOptions)); + return AddDisposable(new IdSchemaDatabaseMappedLogicBase(GetDatabase().GetReadableOf(), this, GetLogicOptions(logicOptions))); } /// @@ -218,7 +234,7 @@ public virtual IContractLogic Get where TContract : class where TEntity : class { - return AddDisposable(new IdSchemaDatabaseMappedLogicBase(GetDatabase().GetReadableOf(), this, logicOptions)); + return AddDisposable(new IdSchemaDatabaseMappedLogicBase(GetDatabase().GetReadableOf(), this, GetLogicOptions(logicOptions))); } /// @@ -233,7 +249,7 @@ public virtual IContractLogic(logicOptions); + return GetInternalLongContractLogic(GetLogicOptions(logicOptions)); } /// @@ -249,7 +265,7 @@ public virtual IContractLogic(logicOptions); + return GetInternalLongContractLogic(GetLogicOptions(logicOptions)); } /// @@ -266,21 +282,21 @@ public virtual IContractLogic(logicOptions); + return GetInternalContractLogic(GetLogicOptions(logicOptions)); } IContractLogic GetInternalLongContractLogic(LogicOptions logicOptions = default) where TResponseContract : class where TEntity : class { - return AddDisposable(new LongIdMappedDatabaseLogicBase(AddDisposable(GetDatabase().GetReadableOf()), AddDisposable(GetDatabase().GetWritableOf()), this, logicOptions)); + return AddDisposable(new LongIdMappedDatabaseLogicBase(AddDisposable(GetDatabase().GetReadableOf()), AddDisposable(GetDatabase().GetWritableOf()), this, GetLogicOptions(logicOptions))); } IContractLogic GetInternalContractLogic(LogicOptions logicOptions = default) where TResponseContract : class where TEntity : class { - return AddDisposable(new IdSchemaDatabaseMappedLogicBase(AddDisposable(GetDatabase().GetReadableOf()), AddDisposable(GetDatabase().GetWritableOf()), this, logicOptions)); + return AddDisposable(new IdSchemaDatabaseMappedLogicBase(AddDisposable(GetDatabase().GetReadableOf()), AddDisposable(GetDatabase().GetWritableOf()), this, GetLogicOptions(logicOptions))); } #endregion @@ -444,6 +460,7 @@ public virtual async Task GetCurrentUserUniqueIdentity(LogicOptions logi var httpContext = ServiceProvider.GetService()?.HttpContext; if (httpContext != null) { + logicOptions = GetLogicOptions(logicOptions); var uniqueIdentity = httpContext.User.FindFirst(nameof(IUniqueIdentitySchema.UniqueIdentity))?.Value; if (uniqueIdentity.HasValue() && logicOptions.UniqueIdentityStrategy != DataTypes.UniqueIdentityStrategy.Default) { diff --git a/src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj b/src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj index 0c9d94c..1466466 100644 --- a/src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj +++ b/src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj @@ -4,7 +4,7 @@ netstandard2.0;netstandard2.1;net6.0;net8.0 AnyCPU;x64;x86 EasyMicroservices - 0.0.1.47 + 0.0.1.48 core of database. EasyMicroservices@gmail.com core,cores,base,client,clients diff --git a/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj b/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj index b5a741b..6559563 100644 --- a/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj +++ b/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj @@ -4,7 +4,7 @@ netstandard2.0;netstandard2.1;net45;net6.0;net8.0 AnyCPU;x64;x86 EasyMicroservices - 0.0.1.47 + 0.0.1.48 core contracts. EasyMicroservices@gmail.com core,cores,base,contract,contracts,dto,dtos diff --git a/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj b/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj index d607696..faeff81 100644 --- a/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj +++ b/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj @@ -4,7 +4,7 @@ netstandard2.0;netstandard2.1;net45;net6.0;net8.0 AnyCPU;x64;x86 EasyMicroservices - 0.0.1.47 + 0.0.1.48 core of database. EasyMicroservices@gmail.com core,cores,base,database diff --git a/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj b/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj index 92c05fa..52f1a91 100644 --- a/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj +++ b/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj @@ -4,7 +4,7 @@ netstandard2.1;net6.0;net8.0 AnyCPU;x64;x86 EasyMicroservices - 0.0.1.47 + 0.0.1.48 ef core of database. EasyMicroservices@gmail.com core,cores,base,database,ef,efcore diff --git a/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj b/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj index a4af226..0656312 100644 --- a/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj +++ b/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj @@ -4,7 +4,7 @@ netstandard2.1;net6.0;net7.0;net8.0 AnyCPU;x64;x86 EasyMicroservices - 0.0.1.47 + 0.0.1.48 ef core of Relational database. EasyMicroservices@gmail.com core,cores,base,database,ef,efcore,Relational