3 ms·
To add on to what you wrote, it amazes me the number of developers that don't understand you can use .Select() to construct named object instances. I'm probably
by progmetaldev 2y ago
To add on to what you wrote, it amazes me the number of developers that don't understand you can use .Select() to construct named object instances. I'm probably using bad terminology, but something like:
.Select(x => new Employee { Name = x.Name, DepartmentName = x.Department.Name }).ToList();
- recursive 2y agoHow do these developers use .Select() then?
- progmetaldev 2y agoInto anonymous types mostly, where you can't pass the type to another method. Example: .Select(x => new { Name = x.Name, DepartmentName = x.Department.Name }).ToList(); Same code as I wrote, except capture in an anonymous type. The documentation practically encourages this.