Last post Feb 08, 2018 01:06 PM by jzero
Feb 07, 2018 05:07 AM|knowledgist|LINK
I have list collection on which I want to execute a for next loop and create a new list collection based on filter some records.
How to filter records in list collection using vb.net.
Feb 07, 2018 11:50 PM|jzero|LINK
I think Linq can help you
Feb 08, 2018 03:38 AM|Eric Du|LINK
According to your description, I think you could use linq query list connections, here is a tutorial, please check the following tutorial:
LINQ to Lists / Collections:
How to: Query an ArrayList with LINQ (Visual Basic):
Feb 08, 2018 12:51 PM|knowledgist|LINK
Thanks ERIC for your reply.
I just go through with it and filtered the records by ID and put the filtered records in another list collection.
Actually, my list collection has 5 properties and many rows returned after filtration and I want to insert only certain properties data in the filtered list.
intUnitID = 2011351662
myTempList = (From t In lstTripSummary.TripSummary() Where t.UnitID = intUnitID Select t).ToList
If myTempList.Count > 0 Then
myList(j).TripStartDate = myTempList(j).TripStartDate
myList(j).TripEndDate = myTempList(j).TripEndDate
myList(j).Name = myTempList(j).VechRegNo & " " & myTempList(j).Make
But I am failed to do by using the above code.
Feb 08, 2018 01:06 PM|jzero|LINK
You can filter and have your final list in a single line
Dim MyFinalLst = (From t in lstTripSummary.TripSummary() Where t.UnitID = intUnitID Select t.TripStartDate, t.TripEndDate, Name = t.VechRegNo & " " & t.Make). ToList