Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<TestContext>(options => options.UseSqlServer("dbconnection"));
}
TestController.cs
private readonly TestContext _db;
public TestController(TestContext db)
{
_db = db;
}
public void Get()
{
DALUser dal = new DALUser(_db);
var list = dal.Get();
}
DALUser.cs
private readonly TestContext _db;
public DALUser(TestContext db)
{
_db = db;
}
public IQueryable<User> Get()
{
_db.Users.AsQueryable();
}
Будет ли dbcontext удаляться и закрываться после выполнения Get () функция?