question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Delete the primary entity and delete the sub entity in cascade. The deleting event of the sub entity cannot be triggered

See original GitHub issue

Delete the primary entity and delete the sub entity in cascade. The deleting event of the sub entity cannot be triggered?

  public class ProductionOrder : AuditedMustHaveTenantEntity<long>
    {
        public string Code { get; set; }

        public List<DispatchOrder> DispatchOrders { get; set; }
    }

    public class DispatchOrder : AuditedMustHaveTenantEntity<long>
    {
        public long ProductionOrderId { get; set; }

       public string Code { get; set; }
    }

       public class DispatchOrderDeletingEventHandler : IEventHandler<EntityDeletingEventData<DispatchOrder>>,ITransientDependency
    {
        public void HandleEvent(EntityDeletingEventData<DispatchOrder> eventData)
        {
              //Delete the productionOrder  to delete the dispatchOrder  in cascade,but this event cannot be triggered
        }
    }

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
netty2019commented, Sep 18, 2022

In this way, the EntityDeletingEvent can be triggered image

0reactions
ismcagdascommented, Oct 19, 2022

Closing since there is a workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cascade Delete - EF Core
Configuring cascading behaviors triggered when an entity is deleted or severed from its principal/parent.
Read more >
Can't delete child entity without deleting parent ...
spring boot - Can't delete child entity without deleting parent entity, regardless of CascadeTypes? - Stack Overflow.
Read more >
Why you should avoid CascadeType.REMOVE for to-many ...
The CascadeTypes REMOVE and ALL, which includes REMOVE, provide a comfortable option to remove an entity together with all its child entities.
Read more >
Cascade deletions ignore current state of entities resulting ...
When the parent entity is removed cascade deletes happen immediately by default but ignores changes already made on child entities.
Read more >
Disadvantages to using ON DELETE CASCADE on every ...
A thing to keep in mind when using cascades is that it can cause conflicts if there's multiple cascade paths. SQL Server and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found