Fix a bug of entity version updating in `ExternalEntitySynchronizer`

pull/14197/head
gdlcf88 3 years ago
parent dfc561723d
commit fbf207ea07

@ -114,8 +114,11 @@ public abstract class ExternalEntitySynchronizer<TEntity, TExternalEntityEto> :
}
else
{
// The version will auto-increment by one when the repository updates the entity.
var entityVersion = eto.EntityVersion - 1;
await MapToEntityAsync(eto, localEntity);
ObjectHelper.TrySetProperty(localEntity, x => x.EntityVersion, () => eto.EntityVersion);
ObjectHelper.TrySetProperty(localEntity, x => x.EntityVersion, () => entityVersion);
await _repository.UpdateAsync(localEntity, true);
}

@ -60,7 +60,7 @@ public class ExternalEntitySynchronizer_Tests : AbpIntegratedTest<ExternalEntity
var book = await repository.FindAsync(bookId);
book.ShouldNotBeNull();
book.EntityVersion.ShouldBe(remoteBookEto.EntityVersion);
book.EntityVersion.ShouldBe(0);
book.Sold.ShouldBe(1);
remoteBookEto.EntityVersion = 1;
@ -70,7 +70,7 @@ public class ExternalEntitySynchronizer_Tests : AbpIntegratedTest<ExternalEntity
book = await repository.FindAsync(bookId);
book.ShouldNotBeNull();
book.EntityVersion.ShouldBe(remoteBookEto.EntityVersion);
book.EntityVersion.ShouldBe(1);
book.Sold.ShouldBe(2);
remoteBookEto.EntityVersion = 0;

Loading…
Cancel
Save