Resharper Convert foreach to LINQ using extension methods

I use Resharper 7, and sometimes when I write foreach loops, it means that I convert it to LINQ. The problem is that I cannot find a parameter where I can choose that LINQ is created using extension methods, and not in the LINQ query form.
I know that this should be possible, because earlier it was used with my old settings (I had to return them to default, because for some reason they completely broke).

This is the foreach loop:

var idList= new List<string>(); foreach (var entity in entityList) { if(entity.EntityPathOrNull==null) idList.Add(entity.Identity); } 

Here's how it is converted:

  var idList = (from entity in entityList where entity.EntityPathOrNull == null select entity.Identity).ToList(); 

And this is how I want it to look like this:

  var idList = entityList.Where(entity => entity.EntityPathOrNull == null).Select(entity=> entity.Identity).ToList(); 

Question: Does anyone know where this parameter is? I searched and google everywhere, but could not find it.

+5
source share
1 answer

This is the only way I can convert it from query syntax. Perhaps this can be done as a standard action. In addition, you will have to call it manually or using a shortcut.

enter image description here

+2
source

Source: https://habr.com/ru/post/1203393/


All Articles