Why does ReSharper tell me “implicitly captured closure”?

前端 未结 5 1838
我在风中等你
我在风中等你 2020-12-04 06:20

I have the following code:

public double CalculateDailyProjectPullForceMax(DateTime date, string start = null, string end = null)
{
    Log(\"Calculating Dai         


        
5条回答
  •  南笙
    南笙 (楼主)
    2020-12-04 06:30

    For Linq to Sql queries, you may get this warning. The lambda's scope may outlive the method due to the fact that the query is often actualized after the method is out of scope. Depending on your situation, you may want to actualize the results (i.e. via .ToList()) within the method to allow for GC on the method's instance vars captured in the L2S lambda.

提交回复
热议问题