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

Activities of "bertusvanzyl"

In the meantime I tried experimenting a bit.

Getting the connection from IActiveTransactionProvider works:

var connection = (SqlConnection) this.ActiveTransactionProvider.GetActiveConnection(new ActiveTransactionProviderArgs
            {
                {"ContextType", typeof(PCMDbContext) },
                {"MultiTenancySide", MultiTenancySide }
            });

But getting the transaction with the same parameters throws an exception.

this.ActiveTransactionProvider.GetActiveTransaction(new ActiveTransactionProviderArgs
                {
                    {"ContextType", typeof(PCMDbContext)},
                    {"MultiTenancySide", MultiTenancySide}
                });

Gives me an exception from inside GetActiveTransaction:

System.NullReferenceException: Object reference not set to an instance of an object. at Abp.EntityFramework.EfActiveTransactionProvider.GetActiveTransaction(ActiveTransactionProviderArgs args)

I see. If the "root" UOW is rolled back, will this new one created inside it alse get rolled back?

That works thank you!

I have a question though, at one point I did try createing a seperate UOW by doing:

using (var uow = UnitOfWorkMakager.Begin()) { uow.Complete(); }

I notice that the uow there does not have SaveChanges. Also, why doesnt calling Complete on that uow, have the same effect as calling SaveChanges on UnitOfWorkManager.Current?

The tests that ship with the solution are mostly Integration Tests, and a few unit tests as well. Threy are integration tests because they touch multiple layers (from the AppService through to the Database).

I have added an issue: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/3050">https://github.com/aspnetboilerplate/as ... ssues/3050</a>

Thank you. In meantime I will split up into year, month and day ints, or use a string.

But if it is not committed, it will not be deleted. Surely the row will still be in the database if the delete was never comitted?

So it is possible for ApplyAbpConceptsForDeletedEntity to be called, even when the entity will not be deleted from the database?

So it should never be called when the UOW is rolled back, only when it it committed? Because in the example above it gets called on a rollback.

When I override ApplyAbpConceptsForDeletedEntity in Dbcontext, it gets called when an entity is deleted.

However, it also sometimes gets called when an entity is deleted, but an exception causes the unit of work to roll back the transaction.

The error causing the rollback is when I delete an entity before deleteing navigation properties on that entity, which then causes an foreign key violation. When this happens, I can see that ApplyAbpConceptsForDeletedEntity gets called, and then the AbpHandledExceptionData event fires afterwards.

I think this might be a bug, because I dont think that ApplyAbpConceptsForDeletedEntity should trigger if the entity was not really deleted from the database because of a UOW rollback.

Yes I saw that, and I could use that, and then filter out only the Entity related events. But I was wondering if there is a way to get only Entity Creation, Update and Deletion events.

Showing 1 to 10 of 23 entries