What does “Access to disposed closure” mean?

后端 未结 1 2026
闹比i
闹比i 2021-01-18 04:08

I have the following code:

public void DequeueRecipe(AuthIdentity identity, params Guid[] recipeIds)
{
   using (var session = GetSession())
   {
      var r         


        
相关标签:
1条回答
  • 2021-01-18 05:07

    Because session is wrapped in a using statement, and the LINQ execution could be defered until it is enumerated.

    Resharper is warning that this could result in an exception, because by the time dbRecipes is enumerated, the session could have have been disposed.

    I'll be honest: I'm not sure the above code could ever fail in the way warned about.

    0 讨论(0)
提交回复
热议问题