How do you promote and/or sell LINQ syntax to colleague that doesn't see the benefit over the manual way of doing thing?
For an example using Linq to Entity/Sql instead of using plain ado.net without any LINQ.
How do you promote and/or sell LINQ syntax to colleague that doesn't see the benefit over the manual way of doing thing?
For an example using Linq to Entity/Sql instead of using plain ado.net without any LINQ.
I would personally start with LINQ to Objects. You don't need any buy-in then - you can use LINQ in your code, let him use foreach loops, conditions etc in his code... and eventually he may notice that your code is more declarative, clearer and shorter.
The decision to use an ORM vs plain ADO.NET is a bigger one, IMO - and one with ramifications well beyond just LINQ syntax.
Show them my projection demo and ask them how much code it would take to do the same thing in ADO.NET. Then point out that in the real world there would probably be repositories and services in between, which you get nearly free with LINQ projections.
Then show them the parallel extensions in .NET 4.
Some of the benefits:
The biggest benefit of all I would call is the first point, the same and simple syntax.
However if your colleague is an expert in the database field he might not want to switch immediately. LINQ does not bring immediate benefits, especially not on ongoing projects, but it makes you more efficient even on mid term in my opinion.
LINQ's great -- but use caution on introducing additional technologies, especially when your company has already settled on a standard. There is nothing more annoying to a developer and costly to a business than having to support 100 different ways of doing the same thing.
We're running into a similar issue at my place of employment. My argument has been that LINQ is a consistent way of querying anything that supports IEnumerable (and others), not just databases. But, when using it to query databases, you get the added benefit of having all your queries strongly typed. You don't get this when doing inline SQL or calling stored procedures. This benefit is huge when entity definitions changes. The compiler will do all the work for you.
I think you could make also make the case that he'd be keeping both the project and his personal skill set in step with the latest tools and developments... just as a bonus to all of the above.
Tell them that you've reconsidered: you now dislike LINQ and think its an awful way to go.
That should do the trick. Just kidding (mostly).
Brown bag lunch session. Project your code on a screen and show how his 20 lines of code can be re-written in 2 or 3.
That's pretty much sold everyone I've shown it to.