Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7791749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:59:09+00:00 2026-06-01T21:59:09+00:00

resharper offers me to make this a local variable, and writes access to modified

  • 0

resharper offers me to make this a local variable, and writes “access to modified closure”

if (filter != null)
{
    if (filter.CityId != 0)
    {
        ads = ads.Where(x => x.Ad.CityId == filter.CityId);
    }
    if (filter.BusinesCategoryId != 0)
    {
        ads = ads.Where(x => x.BusinessCategoryId == filter.BusinesCategoryId);
    }
}

Why do local variable filter?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T21:59:11+00:00Added an answer on June 1, 2026 at 9:59 pm

    Because your query(Where(…)) is not being executed. I assume filter is obtained from a loop?

    Linq query are not executed until they are used. so if you looped though a bunch of filters then started executing them later, the filter value would be wrong in the query.

    A similar question : Access to Modified Closure
    Also: http://devnet.jetbrains.net/thread/273042

    would need to see more code to 100% sure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ReSharper 6.0 gives me the Access to modified closure warning for the dr identifier
ReSharper sometimes hints that I can make some of my random utility methods in
Resharper just prompted me on this line of code: private static bool shouldWriteToDatabase =
Resharper offers a very useful introduce and initialize field xxx action when you specify
Resharper doesn't recognise Rowtests, is this normal? Is there anyway to fix it? (
This confusing feature in ReSharper claims to let you browse external sources from within
From version 5.0 onwards, ReSharper offers a Go To Related Files navigation which offers
Resharper gives a possible null reference warning for the as cast here. Is there
I just started using ReSharper and I'm trying to identify why it thinks this
ReSharper refactored a foreach loop I had to something like this. I wanted to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.