I really like this feature of C# 8. Got a question. What if you do something like this at the class level of a class:
using DbContext myContext = new OurDatabaseContext();
Now, there's an open Entity Framework DbContext at a class level. Does it remain open throughout the lifetime of the class instance? Or does it get closed after some code within the class uses it for something?
Constructor in class is just a function called on creation, it doesn't matter what lifetime you have. And when you go out from scope of this function you drop your session. Therefore you session will be valid only in construction body (scope).