You can use Reflection for this. Without knowing more about how your data objects are configured, I cannot give you a great example, but here's a general idea:
Dim myPerson As New Person myPerson.FirstName = "John" myPerson.LastName = "Doe" myPerson.DOB = #1/1/2000# Dim myUpdates As New Dictionary(Of String, Object) myUpdates.Add("FirstName", "Adam") myUpdates.Add("LastName" , "Maras") myUpdates.Add("DOB" , #1/1/1990#) Dim personType As Type = GetType(Person) For Each kvp As KeyValuePair(Of String, Object) In myUpdates Dim propInfo As PropertyInfo = personType.GetProperty(kvp.Key) If propInfo IsNot Nothing Then propInfo.SetValue(myPerson, kvp.Value) End If Next
source share