You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will make possible to be able to use dbconnection after action execution (for returning IQueryable from controller for 3rd party UI libraries or for making lazy loading available in razor views too).
How to use
Add UseUnitOfWork in the Configure method of your Startup file
publicvoidConfigure(IApplicationBuilderapp){
app.UseAbp();//...other middlewares
app.UseUnitOfWork();//Add before UseMvc
app.UseMvc(...);}
Side effects
If you use UOW middleware;
All your requests will create a UOW even it's not needed.
[UnitOfWork(isTransactional=false)] and similar declerations will not work for controller actions since UOW has already began before the action.
To overcome this potential problems, we suggest you to only use UOW middleware for specific case when you need to an open database connection after MVC action complete. You can configure UseUnitOfWork like that:
app.UseUnitOfWork(options =>{ options.Filter =httpContext =>{//...return true or false to filter request based on URL or other HttpContext properties};});
Finally, you can set options.OptionsFactory to control unit of work options (like transactional or not).
The text was updated successfully, but these errors were encountered:
This will make possible to be able to use dbconnection after action execution (for returning IQueryable from controller for 3rd party UI libraries or for making lazy loading available in razor views too).
How to use
Add
UseUnitOfWork
in the Configure method of your Startup fileSide effects
If you use UOW middleware;
[UnitOfWork(isTransactional=false)]
and similar declerations will not work for controller actions since UOW has already began before the action.To overcome this potential problems, we suggest you to only use UOW middleware for specific case when you need to an open database connection after MVC action complete. You can configure UseUnitOfWork like that:
Finally, you can set options.OptionsFactory to control unit of work options (like transactional or not).
The text was updated successfully, but these errors were encountered: