The Linq query syntax in C# is almost like a SQL but not quite. Example:
from c in db.Customers
where c.City == "London"
select c;
Why is the order of select/from/where upside-down? Because this is more natural and SQL was wrong all along. Just kidding 
To illustrate my point better, look at this SQL query:
SELECT Foo.Something, Foo.MoreOfTheSame, Foo.ColumnName,
Bar.LastName as BarLastName, Bar.FirstName as BarFirstName,
Bar.NeedsExplanation as BarNeedsExplanation
FROM AVeryLongNameForFoo Foo
LEFT JOIN AVeryLongNameForBar Bar ON
Foo.ID = Bar.FooID
If you’ve been writing SQL for years you probably wonder what’s the problem here? For me, it’s mentally parsing the query – in order to see what Foo is I needed to parse the text to the point where the table alias is defined (in the FROM part). For a computer tool this is even more difficult, in fact it’s impossible to provide intellisense at the point where you just typed SELECT Foo.[what should go here?].
Contrast this to the C# Linq example where both you and the compiler (or the IDE) know what each of the elements are at each point in the query. A win-win I’d say.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5