I'm trying to determine why this type isn't serializable (as tested by Type.IsSerializable()
)
<Serializable()> _
Public MustInherit Class WellKnownInstanceCollectionWithTypedId(Of T As WellKnownInstanceWithTypedId(Of IdT), IdT)
Inherits ReadOnlyCollection(Of T)
Public Sub New(ByVal list As IList(Of T))
MyBase.New(list)
End Sub
Public Function GetById(ByVal id As IdT) As T
Return Me.FirstOrDefault(Function(item) item.Id.Equals(id))
End Function
End Class
I know it has something to do with my GetById
function, because if I remove that everything is fine. Can someone tell me what I need to change to have this type be serializable?
Update:
When I change my GetById
implementation as such, everything is fine. Obviously this has something to do with Linq (as suggested below) - can anyone give me further details on why this is so?
Public Function GetById(ByVal id As IdT) As T
For Each i In Me
If i.Id.Equals(i) Then
Return i
End If
Next
Return Nothing
End Function