I have a parent child collection objects and was wondering how to get a single item from the child collection using Linq
Parent Collection
Public Class FaultCodeModel
Public Property ID As Short
Public Property Description As String
Public Property FaultCodeDetails As List(Of FaultCodeDetailModel)
End Class
Child Collection
Public Class FaultCodeDetailModel
Public Property ID As Short
Public Property Description As String
Public Property NotifyPurchasing As Boolean
Public Property NotifyPurchasingAfterHits As Short
Public Property NotifyExpediting As Boolean
Public Property NotifyExpeditingAfterHits As Short
Public Property NotifyBuyer As Boolean
Public Property NotifyBuyerAfterHits As Short
Public Property NotifySupplier As Boolean
Public Property NotifySupplierAfterHits As Short
Public Property NotiifyProPack As Boolean
Public Property NotiifyProPackAfterHits As Short
Public Property NotifyGoodsInTeamLeader As Boolean
Public Property NotifyGoodsInTeamLeaderAfterHits As Short
End Class
I have tried the below Linq query but it is returning multiple child items where the parent ID field is matched.
Dim var = From fcd In FaultCodes Where fcd.FaultCodeDetails.Any(Function(w) w.ID.Equals(faultCodeDetailID))
Select fcd.FaultCodeDetails
How do I get a single item from the child collection?