Closing connections explicitly in Entity Framework

后端 未结 2 476
一整个雨季
一整个雨季 2020-12-28 18:19

Reading the microsoft documentation http://msdn.microsoft.com/en-us/library/bb738684.aspx I see they explicitly open and close the connection

using (EntityCo         


        
2条回答
  •  佛祖请我去吃肉
    2020-12-28 19:00

    It is not necessary because Dispose invoked by using statement will handle it. But it is good habit to explicitly call Close once you know that connection will not be needed any more. For example you don't know how complex the disposal is so you want to free database connection wrapped by entity connection as soon as possible.

提交回复
热议问题