Closed shainegordon closed 9 months ago
Here is a query that is currently NOT possible using repositories, due to CountAsync
's design
_applicationContext.Projects.ByQueryState(QueryState.All).Count()
ByQueryState
in this example is an extension method on IQueryable
which can manipulate QueryFilters
In this case, updating CountAsync
to support a linq expression is probably not the correct solution, and would not be needed if IApplicationDbContext
existed
Hi @shainegordon,
We'll absolutely be adding this in the very near future, I actually started looking into it this morning. This will be optional based on an application setting, when enabled an interface will be available in the application layer exposing all the DbSet
s.
I'll update this issue once a pre-release module is available.
Hi @shainegordon, this is now available in version 4.4.14-pre.0
of the Intent.EntityFrameworkCore
module. You will need to enable the Generate DbContext interface setting as it will not be generated by default.
Please don't hesitate to reach out should you have any comments or questions 🙂.
Hi @shainegordon, this is now available in version
4.4.14-pre.0
of theIntent.EntityFrameworkCore
module. You will need to enable the Generate DbContext interface setting as it will not be generated by default.Please don't hesitate to reach out should you have any comments or questions 🙂.
Great stuff, updated module and updated setting
What problem are you trying to solve?
Intent.Modules.EntityFrameworkCore
will exclude the generation ofIApplicationDbContext
if the moduleIntent.Entities.Repositories.Api
exists in the project.Intent Architect should not be making this decision for the project.
Direct access to the DB context is extremely useful and necessary in some scenarios (e.g. Reports, Queries), without resorting to convoluted repository calls.
Describe the solution you'd like
ApplicationDbContext
should always implementIApplicationDbContext
If teams do want to not allow any access, except via a repository, then making this a setting would also be suitable.