Base solution for your next web application
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?

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

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

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    aaron created
    Support Team

    Related: #6262

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • 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);
            }
    
    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    @system15

    Did you manage to do it ?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    system15 created

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

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    aaron created
    Support Team

    Show your modified code.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    system15 created

    ApplyAbpConceptsForDeletedEntity code is the same as above

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    aaron created
    Support Team

    So you didn't modify anything?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    system15 created

    Nope

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    aaron created
    Support Team

    ...and you expect something to happen?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • 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);
    }
    
    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    aaron created
    Support Team

    What did you expect to happen?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)