I'm a Linq noobie, maybe someone can point me in the right direction. What's wrong here? These anonymous types seem to have the same signatures.
'*** Get all of the new list items'
Dim dsNewFiles = From l1 In list1 _
Where Not (From l2 In list2 _
Select l2.id, l2.timestamp).Contains(New With {l1.id, l1.timestamp})
I wish there were some way to highlight in the above code, but I get the compile error:
Value of type '<anonymous type> (line n)' cannot be converted to '<anonymous type> (line n)'.
on the ".Contains(New With{l1.id, l1.timestamp})"
I assume it thinks the anonymous types are different in some way, but the id and timestamp columns are the same in either list. They are also in the same order. What else can be different between the two?
[Edit 7/10/2009 16:28 EST]
I tried the suggested code from user Meta-Knight (New With {Key l1.id, l1.timestamp}) and it fixed the compile error. However, when I ran the code with List1 and List2 as follows:
List1 List2
id timestamp id timestamp
-- ---------- -- ----------
01 2009-07-10 00:00:00 01 2009-07-10 00:00:00
The result was:
dsNewFiles
id timestamp
-- ----------
01 2009-07-10 00:00:00
It should have been an empty list.