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

前端 未结 6 1937
野趣味
野趣味 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:14

    I just asked this same question over on Programmers.SE. Robert Harvey gave a great answer.

    In general, you don't need to use Using statements with Entity Framework data contexts. Lazy collections is one of the reasons why.

    I encourage you to read the entire answer on Programmers.SE as well as the links Robert provides in the answer.

提交回复
热议问题