I've been playing around with LINQ to Objects and have come across something quite odd...
Say we have this statement:
Dim myCustomers = From customer In customers _
Where customer.Id = 5 _
Select customer.Id, _
FullName = customer.FirstName & _
" " & customer.LastName
For Each customer In myCustomers.Distinct()
Console.WriteLine(customer.FullName)
Next
FullName becomes a ReadOnly Property here and acts as
if it belonged to the Customer class.
Now, say we take out the first field in the select list:
Dim myCustomers = From customer In customers _
Where customer.Id = 5 _
Select FullName = _
customer.FirstName & " " & _
customer.LastName
For Each customer In myCustomers.Distinct()
Console.WriteLine(customer.FullName)
Next
This doesn't compile? It treats FullName now as an
extension of String?
Error 1 'FullName' is not a member of 'String'.
That makes no sense to me.. Maybe it's because it's after 1am,
but I'd love if someone wanted to make some sense of that...