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
Hi,
Do we have something like AddDbContextFactory?
On blazor server application, we have this factory method to add DbContext into service.
So we can inject the factory and not the actual object.
And when required, we can use "using" pattern to dispose it automatically.
await using (var db = _dbFactory.CreateDbContext())
{
_cats = db.ProdCategoryTbls.Where(o => o.IsActive)
.OrderBy(o => o.Name).ToList();
_cats.AddRange(
db.ProdCategoryTbls.Where(o => o.IsActive == false)
.OrderBy(o => o.Name).ToList()
);
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
Do we have something like AddDbContextFactory?
On blazor server application, we have this factory method to add DbContext into service.
So we can inject the factory and not the actual object.
And when required, we can use "using" pattern to dispose it automatically.
await using (var db = _dbFactory.CreateDbContext())
{
_cats = db.ProdCategoryTbls.Where(o => o.IsActive)
.OrderBy(o => o.Name).ToList();
_cats.AddRange(
db.ProdCategoryTbls.Where(o => o.IsActive == false)
.OrderBy(o => o.Name).ToList()
);
}
Beta Was this translation helpful? Give feedback.
All reactions