3 ms·
A `Select` to a tuple or anonymous class which you have to carry around all the way. If you look at how a LINQ query gets translated to a method chain (e.g. vi
by brewmarche 2y ago
A `Select` to a tuple or anonymous class which you have to carry around all the way.
If you look at how a LINQ query gets translated to a method chain (e.g. via SharpLab or let Rider/ReSharper rewrite them) you'll notice that multiple `from`s or `let`s can become quite ugly.
- progmetaldev 2y agoTo 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.
- sedatk 2y agoOh that's convenient, that's for sure.