How to effectively dispose unmanaged resources?
i have some questions about disposing objects in .NET.
I work with a .NET API that connects to a SQL Server database via Entity Framework.
Basically, the hierarchy of calls are: Controller -> Scoped Service -> Scoped Repository -> DbContext.
As we are increasing number of users of the API and our application isn't very optmized, i went into studying about disposing objects, specially unmanaged resources (those not "deletable" by GC right? How to know if a object is unmanaged btw?).
I wrote some questions in the code snippet bellow. As I'm still new to this (never needed to write explicitly dispose methods before), I'm open to opinions and experiences you all had in your projects and investigations!
I work with a .NET API that connects to a SQL Server database via Entity Framework.
Basically, the hierarchy of calls are: Controller -> Scoped Service -> Scoped Repository -> DbContext.
As we are increasing number of users of the API and our application isn't very optmized, i went into studying about disposing objects, specially unmanaged resources (those not "deletable" by GC right? How to know if a object is unmanaged btw?).
I wrote some questions in the code snippet bellow. As I'm still new to this (never needed to write explicitly dispose methods before), I'm open to opinions and experiences you all had in your projects and investigations!