Do I need to force a Dispose after a LINQ query?

前端 未结 6 1934
野趣味
野趣味 2021-02-12 22:49

My DBA says that there are way too many connection open and he thinks it is my code in .net that is leaving them open.

I am using LINQ querys and EF code first.

6条回答
  •  梦谈多话
    2021-02-12 23:27

    By default DbContext automatically manages the connection for you. So you shouldn't have to explicitly call Dispose.

    Blog post on the subject: Link

    But I believe not disposing can cause performance issues if you're processing a lot of requests. You should add a using statement to see whether or not it's causing a problem in your case.

提交回复
热议问题