I am a bit new to linq, I am only using linq for filtering the data. Now, I want to write a query for the below:
For Each k As String In con.Numbers.Keys
con.Numbers(k).Primary = False
Next
Con.Numbers is a dictionary, but now I converted it into a list, hence the above code wont work with list, could you please tell me how I can achieve it with Linq is the Con.NUmbers is a list. Thank you.
Additional Info:
Class Structure is :
Public Class ContactCon
Property ConId As String
Property ConRowID As String
Property Title As String
Property Mob1 As String
Property Mob2 As String
Property Land1 As String
Property Land2 As String
Property Email1 As String
Property Email2 As String
Property Fax1 As String
Property Fax2 As String
Property Primary As Boolean
Public Sub New()
ConId = ""
ConRowID = ""
Title = "Contact1"
Mob1 = ""
Mob2 = ""
Land1 = ""
Land2 = ""
Email1 = ""
Email2 = ""
Fax1 = ""
Fax2 = ""
Primary = False
End Sub
End Class
Don’t know if I have misunderstood you somewhere.
Not sure why you want to use LINQ specifically. This is perfectly clear:
If for some reason you want LINQ-like syntax, you could use the
List(T).ForEach:For course, this is not “real” LINQ, but again, I’m not sure why it would matter.
If you are really forced (?) to use LINQ, you might do:
But of course the code is nonsense. Don’t do this — stick to what is clear and obvious, which in this case means just looping over the list.
EDIT
Fixed terrible misuse of
Function