Edit: I read the question as "Help me sell linq to my boss" rather than "linq training". Linq is extremely useful and it's use should be encouraged, but I don't think that it requires training. It's all very well documented online, and the concepts should be familiar to anyone who's ever written a SQL query.
We just had one developer (me) do a bunch of reading and give a quick intro to other developers and went from there.
As for my original linq justification:
The biggest selling point for me is that linq lets you perform many list manipulations in a way that does a lot better job of expressing your intent than the non-linq way.
If you look at all of the places in your code where you're looping over a collection (whether with a for loop, or a foreach loop) chances are good you're doing one of (or a combination of) three things:
- mapping (transforming each element into something else)
- filtering (finding all elements that match a certain criteria)
- aggregating (eg. calculating the sum of a collection of integers)
For example, filtering items out of a list is a reasonably common operation (at least for me). The non-linq way requires a foreach loop and an if at minimum:
foreach(Car c in cars)
{
if (c.Color == "Red")
{
newList.Add(c);
}
}
There's a lot of accidental complexity there for what should be a simple operation. Compare the linq equivalent:
var filteredItems = from car in cars
where car.Color == "Red"
select car;
In my mind, that's a lot more readable, and exactly expresses it's intent.