Base solution for your next web application

Activities of "bertusvanzyl"

All attempts to download a project from <a class="postlink" href="https://aspnetzero.com/Download">https://aspnetzero.com/Download</a> fails with 500 internal error.

I am doing some housekeeping inside a background worker. Part of this is writing entries into certain tables etc. Some of these tables implement ICreationAudited, so I would like to set the UserID for the current UOW so that the CreatorUserId columns is automatically updated to an BackgroundWorker user on the tenant.

I can already set the TenantID using UnitOfWorkManager.Current.SetTenantId() when I start the using block, but I am not sure how to set the user ID as well.

Any advice?

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 have a custom Repository. Everything is working fine, but I have a small issue I am unable to solve.

Currently I get the SqlConnection by injecting IDbContextProvider, and then this.DbContextProvider.GetDbContext().Database.Connection;

The problem is that I would like to use the current transaction on the UOW as well, if there is one.

I did see in thispost ([https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=9725&p=21656&hilit=Uow+connection#p21656])) that I can inject IActiveTransactionProvider.

However, I could not find any documentation on the ActiveTransactionProviderArgs parameter. Is there a guide or documentation somewhere I can consult?

Or will the

{"ContextType", typeof(YourAppDbContext) },
                {"MultiTenancySide", MultiTenancySide }

parameter always work for me?

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 an entity, with soft delete enabled.

I want to set some metadata on this entity, and then delete it.

However, if I call Update on the repository, and then Delete, the update is completely ignored. The entity ends up with IsDeleted set to true, but the updates are not there.

If I call Delete before Update (just trying different stuff, I know this is not proper), the opposite happens. The update is successful, bit IsDeleted is NOT set to true.

Am I doing something wrong here? How can I update the entity, and then delete it immediately?

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.

When sending a datetime back from the angular application, it gets changes to UTC, and the API and the database use the UTC date. This is good. However, sometimes, when sending a datetime back from the browser into the API, I want the specific date to be stored in the database etc.

For example, when speciifying a birthdate, I send back 1981-09-25 to the API. This is the persons birthday, regardless of timezone.

If the DTO is of type DateTime, the API receives something like 1981-09-24 10:00:00, because it has been converted to UTC.

So my question is, how do I suppress the conversion to UTC for specific properties on a DTO?

For now I am sending the year, month, and day as seperate integers, but I am not happy with this clunky workaround. Otherwise I might end up sending a string? What do you guys suggest?

Thank you.

Showing 1 to 10 of 34 entries