I'm trying to create an Inherit class that can interface with a datarow and auto-fill all of its data. To do that I've create a Dictionary like this:
reyRelation As New Dictionary(Of String, String)
rey.Add("Id", "id_user")
rey.Add("Name", "name")
rey.Add("Surname", "surname")
where the "keys" are the name of the property, and the "values" are the name of column inside the DataRow object.
So, I want to create a function called "load" for example, like this:
Try
Dim row As DataRow = Me.getRowById()
For Each key As String In Me.reyRelation.Keys
Me.key = getRowById(reyRelation.Item(key))
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "MODEL Error in Utente: Errore caricamento dati", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Where:
1 - The
Me.getRowById()
is a function inside the class declaredMustOverride
so every class can use the correct dataAdapter.2 - The
Me.key
is obviously the focus of my question: I can't do something like this because I find an error, so that's the question: How I can access from the stringkey
at the property to set its value?
I hope I was clear with the explanation! Thank you!
Aucun commentaire:
Enregistrer un commentaire