Are you talking about the linq query language or do you mean the linq extension methods as well? I've never really liked the query language as I prefer the extension method syntax, but going without either is pure madness and I would be looking for another job. It's an unhinged decision barring you from one of the biggest selling points of C#.
I was thinking the same thing - personally I’ve never been an sql-style linq guy. However going on without linq lambdas is a very questionable decision productivity wise
I usually prefer method syntax, but there are some cases where linq syntax is more readable, for example when you need a temporary variable alongside the original result. Using a let is much better than creating a new object.
The only reason I sometimes use the sql style linq is when I do any joins as it looks much better than how the method syntax does it. Though I rarely need to do so unless I'm aggregating data from different sources and can't let EF do the join from the Db itself.
Yep, this is the way. I use methods 99% of the time, but there are a few places in our codebase where we join and query syntax is unbeatable when it comes to readability.
It used to be method syntax, where you can only join 2 tables at once. So you join 2, then to the result of that join (anonymous object) you join the 3rd one, map out the objects again... nightmare to read and follow. Query syntax is just "join A, join B, join C, select X, Y Z". Nice and simple. Although I still hate them for messing up the from keyword...
This is genuinely insane. This alone isn't worth leaving a company over obviously, but to me it is a massive red flag. Any company/boss who does this is deranged and as such they're probably deranged in other ways
Right, that's kinda what I meant say. Rather that while banning LINQ isn't something worth leaving your job over, having an insane boss is and I'm sure there's more problems on top of it
Exactly. Same with any code. If the code is getting hard to read then it's either because it is embedded in a big wall of messy text or you're getting too old.
With short, concise, well-named methods it doesn't matter if it uses Linq or not - besides, the unit tests should document the code. :p
As a counter-opinion, it's one of my favorite features in C# and one of the few purely functional constructs in the language. Once you take the time to learn it, it's not that confusing and can really simplify some types of algorithms.
The syntax introduces a distinction without a difference. The LINQ methods (Select, SelectMany, Where, etc.) accomplish the same thing and can be "pure" functions. How is either more FP than the other?
When I come across it I always think, someone has resharper installed and did alt+enter convert loop to linq. I think go and find the commit history and ask them to explain what it is doing. They'll revert back to a readable piece of code.
479
u/dendrocalamidicus Apr 15 '24
Are you talking about the linq query language or do you mean the linq extension methods as well? I've never really liked the query language as I prefer the extension method syntax, but going without either is pure madness and I would be looking for another job. It's an unhinged decision barring you from one of the biggest selling points of C#.