Skip to content

Commit

Permalink
Merge pull request #118 from Ali-YousefiTelori/develop
Browse files Browse the repository at this point in the history
fix empty uid of children
  • Loading branch information
Ali-YousefiTelori authored Dec 29, 2023
2 parents 7c4c06f + 7207708 commit 8b07c28
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.84</Version>
<Version>0.0.0.85</Version>
<Description>asp core servces.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,services,asp,aspnet</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.84</Version>
<Version>0.0.0.85</Version>
<Description>asp core servces.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,services,asp,aspnet,aspcore,efcore</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.84</Version>
<Version>0.0.0.85</Version>
<Description>core of database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,client,clients</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0;netstandard2.1;net45;net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.84</Version>
<Version>0.0.0.85</Version>
<Description>core contracts.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,contract,contracts,dto,dtos</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,23 @@ await ActivityChangeLogLogic.ChangeLogAsync<TEntity, TId>(getResult.Result.Selec

#region Add

IEntityEntry[] FixUniqueIdentity<TEntity>(IEntityEntry[] entityEntries)
{
if (!typeof(IUniqueIdentitySchema).IsAssignableFrom(typeof(TEntity)))
return entityEntries;
var find = entityEntries.Where(x => x is IUniqueIdentitySchema).Cast<IUniqueIdentitySchema>().FirstOrDefault(x => x.UniqueIdentity.HasValue());
if (find == null)
return entityEntries;
foreach (var item in entityEntries)
{
if (item is IUniqueIdentitySchema uniqueIdentity)
{
uniqueIdentity.UniqueIdentity = find.UniqueIdentity;
}
}
return entityEntries;
}

/// <summary>
///
/// </summary>
Expand All @@ -820,7 +837,7 @@ public async Task<MessageContract<TEntity>> Add<TEntity>(IEasyWritableQueryableA
where TEntity : class
{
var result = await easyWritableQueryable.AddAsync(entity, cancellationToken);
foreach (var entityEntry in easyWritableQueryable.Context.GetTrackerEntities().ToArray())
foreach (var entityEntry in FixUniqueIdentity<TEntity>(easyWritableQueryable.Context.GetTrackerEntities().ToArray()))
{
if (entityEntry.EntityState != EasyMicroservices.Database.DataTypes.EntityStateType.Added)
continue;
Expand Down Expand Up @@ -856,7 +873,7 @@ public async Task<ListMessageContract<TEntity>> AddBulk<TEntity>(IEasyWritableQu
where TEntity : class
{
var result = await easyWritableQueryable.AddBulkAsync(entities, cancellationToken);
foreach (var entityEntry in easyWritableQueryable.Context.GetTrackerEntities().ToArray())
foreach (var entityEntry in FixUniqueIdentity<TEntity>(easyWritableQueryable.Context.GetTrackerEntities().ToArray()))
{
if (entityEntry.EntityState != EasyMicroservices.Database.DataTypes.EntityStateType.Added)
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0;netstandard2.1;net45;net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.84</Version>
<Version>0.0.0.85</Version>
<Description>core of database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.84</Version>
<Version>0.0.0.85</Version>
<Description>ef core of database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,ef,efcore</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.84</Version>
<Version>0.0.0.85</Version>
<Description>ef core of Relational database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,ef,efcore,Relational</PackageTags>
Expand Down

0 comments on commit 8b07c28

Please sign in to comment.