I have a Customer object which has a collection of ContactNumbers.
Is it possible with LINQ to get a list of Customers where one of the contact numbers = ‘123’?
Public Class Customer
Public Overridable Property ContactNumbers As List(Of ContactNumber)
End Class
Public Class ContactNumber
<Required()>
Public Property ID As Integer
<Required()>
<StringLength(20)>
Public Property Number As String
Public Overridable Property Type As ContactNumberType
Public Property Primary As Boolean
End Class
Dim findnumber as String = '123'
Dim customers = db.customers.tolist
customers = customers.Where..... ?
Try the following
The trick here is the
Anyfunction. This will returnTrueif any of the items in the collection match the predicate. In this casey.Number = 123