I am currently referencing a generic DataSet via an index and would like to convert this to a strongly-typed DataSet of the table type. The issue is that my index to the DataRow is a variable.
Currently I am doing the following where the History_Column value is pulled from the database.
e.Dr[c.History_Column.ToString()] = Entry;
I would like to define the DataRow ('Dr' in the example) as a type of the table so I can do something similar to the following:
e.Dr.COLUMN_NAME = Entry;
How can I use dynamic variables in this fashion?
Thanks!
You could use a dynamic type to get you part of the way there, but your goal sounds kind of contradictory.
dynamic Dr = new ExpandoObject();
Dr.whatever = 6;
Dr.anything = "asdf";
If you use ExpandoObject
with dynamic
, you can assign any property.