This is more of a "How can I do this in Visual Studio/other refactor tool?" rather than a coding question.
The screenshot below shows an unresolved database object, checklists, (In this case an IMongoQueryable) being passed to a foreach loop.
In this specific case, the loop is causing "N" queries to be issued. It would be more efficient to resolve the dataset by calling ToListAsync() before passing to the loop, as only one query would be issued.
I believe there are hundreds of cases where this is happening in our solution, but the codebase is 10 years old, massive, badly architected, badly performing (not my code) and I don’t know how to find them.
How can I find all instances of a type (e.g. IMongoQueryable) being used inside a loop, like the one below?
Source: Visual Studio Questions