Reputation: 38392
Why is it the syntax of the Select property in the LinqDataSource so different from Linq I would write inline in C#? I mean like:
new (Id As MyId, Name As MyName)
vs
new (MyId = Id, MyName = Name)
And the syntax diverges more when you start doing things like concatenation in the projection. I am using this with a Entity Data model as the provider, if that has anything to do with it.
I would have expected something called a LinqDataSource would simply allow you to supply a compiled Linq query and be done with it.
Also I could find no documentation on the syntax of what is expected for the Select property other than the most simple cases of aliasing the fields. The Linq Concat command doesn't work, and it was only a stroke of luck that I found a blog where someone figured out an alternative. So in the future when trying to do any other manipulations I pretty much can only take wild guesses in the dark.
Upvotes: 2
Views: 1714
Reputation: 35761
I think it is because the as
keyword has already a different meaning in the language. The chosen syntax resembles the syntax of default parameters (.net 4.0 following) and is pretty clear IMHO.
Note that this explicit syntax is only necessary when a property name for an anonymous type cannot be inferred or is ambigous.
Upvotes: 1