I need your suggestions on the Below implementation.
I'm using Entity Framework for my ASP.NET WEB API Project
my program Flow is: Repository->BusinessLayer->Controller
my Context name is: UtmDataContext
In Repositories I'm using code some thing like this:
using (SqlConnection objConnection = new SqlConnection(connstr))
{
DbCompiledModel compiledModel = UtmCompiledModel.CreateCompiledDataModel(objConnection, schema);
using (var dataContext = new UTMDataContext(objConnection, compiledModel, true))
{
/*Doing some stuff here*/
}
}
in the above code schema is a parameter that comes from the user.
my Project requires to have multi-tenant architecture for entity framework. So I'm Building the model and then feeding it to the UtmDataContext object.
But, I doubt that, is entity framework really closing my objConnection?
Can you please help me on this? Please let me know if you need any further information
Thanks In Advance
一旦using {}块中的所有内容都已执行,您的SqlConnection将被关闭并对其进行dispose()调用。
When using using
on an object implementing IDisposable
, the compiler interprets the code as having a try/finally block. The finally
block calls the Dispose
method of the object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.