model = brands.Select(item => Ma...">

What is this ReSharper "conversion to group of methods" fragment?

enter image description here

Code before changes:

List<ProductBrandModel> model = brands.Select(item => Mapper.Map<ProductBrand, ProductBrandModel>(item)).ToList(); 

Code after improvement:

 List<ProductBrandModel> model = brands.Select(Mapper.Map<ProductBrand, ProductBrandModel>).ToList(); 

What does it do? Is it an implicit start of this mapping for each item in the brands collection?

+8
c # resharper
source share
2 answers

Since you directly pass the parameter of the lambda expression to the Mapper.Map method, it is exactly equivalent to Mapper.Map this method directly as a projection for Select . The Mapper.Map signature Mapper.Map compatible with the Func<TSource, TResult> delegate, so R # suggests using a group of methods directly, rather than a lambda expression.

+10
source share

The first line creates a method that immediately calls the Mapper.Map function. This is optional since the Mapper.Map method matches the expected Select definition and can directly call Mapper.Map. Resharper modifies it so that only 1 method is called, and the additional method is not generated by the compiler.

+3
source share

All Articles