Skip to content

Instantly share code, notes, and snippets.

@janv8000
Created March 7, 2014 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janv8000/9407469 to your computer and use it in GitHub Desktop.
Save janv8000/9407469 to your computer and use it in GitHub Desktop.
<TestFixture()>
Public Class StackOverflowQuestion6556077Test
Private _originalList As Record()
Private Class Record
Public Country As String
Public CountryID As Integer
End Class
<SetUp>
Public Sub SetUp()
_originalList = {New Record With {.Country = "Spain", .CountryID = 1},
New Record With {.Country = "Spain", .CountryID = 1}}
End Sub
<Test()>
Public Sub TestWithExplicitAnonymousType()
Dim query = From c In _originalList Select New With {.Country = c.Country, .CountryID = c.CountryID}
Assert.AreEqual(query.Distinct.Count(), 1)
End Sub
<Test()>
Public Sub TestWithAnonymousTypeFromQuery()
Dim query = From c In _originalList Select c.Country, c.CountryID 'No explicit New here!
Assert.AreEqual(query.Distinct.Count(), 1)
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment