I started a new project using Aspnet Boiler plate, but no longer feel like using repositories and tons of hidden engineering done behind the scene.
Hence looking forward to get instance the db context instantiated by Abp repositories framework and
How do I fetch that instance please?
- work with Ef core LINQ queries directly.
You can get an instance of DbContext
using GetDbContext()
of IDbContextProvider
.
private readonly YourDbContext _ctx;
public YourService(IDbContextProvider<YourDbContext> dbContextProvider)
{
_ctx = dbContextProvider.GetDbContext();
}
- Commit my changes directly using SaveChanges, rather than relying on abstracted transactions.
You can disable transactions by applying [UnitOfWork(IsDisabled = true)]
attribute
Here is a relevant article on transaction management with ASP.NET Boilerplate.