How about a dictionary?
<Serializable()>
Public Class UserData
Public Property UserGUID As GUID
Public Property Parameters As Dictionary(Of String, String)
End Class
Then you could have the dictionary filled with things like:
{{"Name", "Sir Launcelot of Camelot"},
{"Quest","To seek the Holy Grail"},
{"Favorite Color","Blue"},
{"Favorite Place","Castle Anthrax"},
...
}
And you could have a table that looks like this:
UserGUID | Parameter | Value
-----------------------------------------------------------
AZ-12-43-EF | Name | Sir Launcelot of Camelot
AZ-12-43-EF | Quest | To seek the Holy Grail
AZ-12-43-EF | Favorite Color | Blue
34-DF-E4-22 | Name | Sir Galahad of Camelot
34-DF-E4-22 | Quest | I seek the Holy Grail
34-DF-E4-22 | Favorite Color | Blue. No yel-- Auuuuuuuugh!
If you need more complex values for the parameters, maybe you could store a JSON string that goes with each parameter? ... or if you've gone that far, you might make all the user data a JSON string ;)
Edit:
To display the data, you have several options, if you know what entry you want, you can simply grab it out of the dictionary:
If userData.Parameters.ContainsKey("Name") Then
textBoxName = userData.Parameters("Name")
Else
'Name value not found
textBoxName = "Enter name here"
End If
If you want to display all the parameters in a table though, you'll have to convert the dictionary into something else first. For example, to bind to a DataGridView
, you could do the following:
Dim parameterList = From entry In userData.Parameters
Select New With { .Parameter = entry.Key, entry.Value }
dataGridView1.DataSource = parameterList.ToArray()
In the example above parameterList
is actually an IEnumerable
of an anonymous type that has two properties, Parameter As String
and Value As String
.
Resources for learning more about Dictionary
:
... and some StackOverflow questions: