. In addition, <T> throws an exception
I have the following code:
Public Shared Function GetAvailableManufacturers() As List(Of Manufacturer)
'first get all the live orders and extract their mfrs'
Dim sos As List(Of OrderForm) = GetFormsByStatus(StockStatus.Building)
Dim unavailableMfrs As New List(Of Manufacturer)
For Each so As StockingOrder In sos
unavailableMfrs.Add(so.Source)
Next
'then remove all mfrs with an open SO from a list of all mfrs'
Dim allMfrs As List(Of Manufacturer) = Manufacturer.GetManufacturers
Return allMfrs.Except(unavailableMfrs) <----- error here
End Function
Explanation of what is doing above:
GetFormsByStatus()self-evidentGetManufacturers()returns a list of all manufacturers in the database
My idea of accessing manufacturers was to get a list of all manufacturers in my open forms, and then get a list of all manufacturers and exclude all manufacturers in the first list, illustrated as follows (pseudo):
List A: {1,2,3,4,5,6,7,8,9,10}
List B: {5,7,10}
Result: {1,2,3,4,6,8,9}
I set my class Manufactureraccording to this article so that it can be compared, but I still get this error:
Unable to pass an object of type '
<ExceptIterator>d__92'1[csCore.Manufacturer]'for inputSystem.Collections.Generic.List'1[csCore.Manufacturer]'.
, , GetFormsByStatus() 0 , , , , Except() , 0 . - , ?
!
The problem is that Enumerable.Except returns IEnumerable<T>, but your return type List(Of T).
Change your last line to:
Return allMfrs.Except(unavailableMfrs).ToList()