I'm relatively new with LINQ, but I'm going to be getting into it a lot more. Is the following a practical application of LINQ, or is there a better way to do something like this?
Public Shared Function GetItems(ByVal itemsList As List(Of OrderItem),
ByVal whichForm As ItemsFor, ByVal formID As Integer) As List(Of OrderItem)
Dim items As New List(Of OrderItem)
Select Case whichForm
Case ItemsFor.MfrCredit
Dim query = From oi As OrderItem In itemsList _
Where oi.ManufacturerCreditID = formID Select oi
items = query
Case ItemsFor.CustomerCredit
Dim query = From oi As OrderItem In itemsList _
Where oi.CustomerCreditID = formID Select oi
items = query
Case ItemsFor.Invoice
Dim query = From oi As OrderItem In itemsList _
Where oi.InvoiceID = formID Select oi
items = query
Case ItemsFor.PurchaseOrder
Dim query = From oi As OrderItem In itemsList _
Where oi.PurchaseOrderID = formID Select oi
items = query
Case ItemsFor.Quote
Dim query = From oi As OrderItem In itemsList _
Where oi.QuoteID = formID Select oi
items = query
Case ItemsFor.StockingOrder
Dim query = From oi As OrderItem In itemsList _
Where oi.StockingOrderID = formID Select oi
items = query
End Select
Return items
End Function
I was thinking if I could get the property name somehow as an object I could just do one LINQ statement, but I'm not sure exactly how...
Thanks!