Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to handle deleted entity using ApplyAbpConceptsForDeletedEntity (concurrency) #6325


User avatar
0
system15 created

Hi there does anyone know how to handle delete concurrecy if an entity gets deleted having two tabs opened with the same entites and deleting the entity in the first tab and trying to make changes to the entity in the second tab and saving that?


12 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @system15,

    You can refer to EF Core's documentation https://docs.microsoft.com/en-us/ef/core/saving/concurrency

  • User Avatar
    0
    aaron created
    Support Team

    Related: #6262

  • User Avatar
    0
    system15 created

    @aaron yes it's similar I'm trying to apply the solution of:

    protected override void ApplyAbpConceptsForModifiedEntity(EntityEntry entry, long? userId, EntityChangeReport changeReport)
    {
        if (entry.Entity is MyRowVersionEntity)
        {
            entry.OriginalValues["RowVersion"] = entry.CurrentValues["RowVersion"];
        }
    
        base.ApplyAbpConceptsForModifiedEntity(entry, userId, changeReport);
    }
    

    To

    protected override void ApplyAbpConceptsForDeletedEntity(EntityEntry entry, long? userId, EntityChangeReport changeReport)
            {
                base.ApplyAbpConceptsForDeletedEntity(entry, userId, changeReport);
            }
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    @system15

    Did you manage to do it ?

  • User Avatar
    0
    system15 created

    @ismcagdas Nope can you let me know any useful changes that may help.

  • User Avatar
    0
    aaron created
    Support Team

    Show your modified code.

  • User Avatar
    0
    system15 created

    ApplyAbpConceptsForDeletedEntity code is the same as above

  • User Avatar
    0
    aaron created
    Support Team

    So you didn't modify anything?

  • User Avatar
    0
    system15 created

    Nope

  • User Avatar
    0
    aaron created
    Support Team

    ...and you expect something to happen?

  • User Avatar
    0
    system15 created

    Well yes the following code works if two users are editing the same entity:

    protected override void ApplyAbpConceptsForModifiedEntity(EntityEntry entry, long? userId, EntityChangeReport changeReport)
    {
        if (entry.Entity is MyRowVersionEntity)
        {
            entry.OriginalValues["RowVersion"] = entry.CurrentValues["RowVersion"];
        }
    
        base.ApplyAbpConceptsForModifiedEntity(entry, userId, changeReport);
    }
    
  • User Avatar
    0
    aaron created
    Support Team

    What did you expect to happen?