Yes I would like to throw UserFriendlyException but where I can catch the DbConcurrencyError ?
Expected behaviour: using IRepository<MyEntity> if DbConcurrencyError happens I want to catch the exception and display to user a custom message instead of error.
Now I have in response to client;
{
"result": null,
"targetUrl": null,
"success": false,
"error": {
"code": 0,
"message": "An internal error occurred during your request!",
"details": null,
"validationErrors": null
},
"unAuthorizedRequest": false,
"__abp": true
}
and in log
ERROR 2018-01-23 17:43:24,295 [10 ] Mvc.ExceptionHandling.AbpExceptionFilter - Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
Abp.Domain.Uow.AbpDbConcurrencyException: Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions. ---> Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyException(Int32 commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected)
This is my repository
public class OspiteRepository : IOspiteRepository
{
private readonly IRepository<OspiteData> _ospiteDataRepository;
public OspiteRepository(IRepository<OspiteData> ospiteDataRepository)
{
_ospiteDataRepository = ospiteDataRepository;
}
public void UpdateOspite(Ospite ospite)
{
_ospiteDataRepository.Update(ospite.Snapshot);
}
}
No. Just did now for all save overrides. The code pass in my context on those methods.. but the exception is not raised here but ahead in code. In logs.txt I can see Database operation expected to affect 1 row(s) but actually affected 0 row(s)
public override Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = new CancellationToken())
{
try
{
return base.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken);
}
catch (Exception e)
{
throw;
}
}
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
{
try
{
return base.SaveChangesAsync(cancellationToken);
}
catch (Exception e)
{
throw;
}
}
Yes I did, but SaveChanges on my context is not raised.
Always the base method is called. I guess I'm missing something but i don't know what.
I reply to myself.
After looking to Abp.EntityFrameworkCore.Test and BlogUrlChangeEventData I realised that Aggregate's DomainEvents are raised only if the Aggregate itself is updated by a repository.
So, as my Domains Entities are unaware of persistence, I have to use EventBus directly.
Hi, some news for my tests?
Have you checked my code?
Thanks
Email sent to <a href="mailto:[email protected]">[email protected]</a>
Thanks.
Hi @ismcagdas, some news for my problem ?
Yes sure. As I said, the module work pefectly. Only tests have problems. I've migrated it from core 1.1 where tests are executed correctly.
I would like to have also some guide on how create test with custom plugin modules .
Thanks
Thank you @ismcagdas,
Can you provide me a right way to migrate the previous settings to the new concept? Which interface or service should I use?
We have already used (and serialized in appsettings) the previous settings for every tenant, but they are changed (like UsePunctuations => RequireNonAlphanumeric) . Plus, we need to manually validate the password like the previous password checker because some users does not require restriction (eg. Service Account).
Thanks