
Code before the changes:
List<ProductBrandModel> model = brands.Select(item => Mapper.Map<ProductBrand, ProductBrandModel>(item)).ToList();
Code after the improvement:
List<ProductBrandModel> model = brands.Select(Mapper.Map<ProductBrand, ProductBrandModel>).ToList();
What is this doing? Is it implicitly running that mapping on every item in the brands collection?
Since you’re directly passing the parameter of the lambda expression to the
Mapper.Mapmethod, it is exactly equivalent to specifying this method directly as the projection forSelect. The signature ofMapper.Mapis compatible with theFunc<TSource, TResult>delegate, so R# suggests to use the method group directly rather than a lambda expression.