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

Access DbContext in DomainService #4212


User avatar
0
ajayak created

I want to detach a nested entity to avoid automatic db insertions. Here is sample code:

foreach (var refund in order.Refunds)
            {
                context.Entry(refund).State = EntityState.Detached;
            }

How I get context in DomainServiceBase class?


2 Answer(s)
  • User Avatar
    0
    ajayak created

    Fixed by injecting IDbContextProvider<DbContext> contextProvider

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks for the feedback @ajayak :)