I am writing a wrapper around some data library that executes sql statements and returns results.
The ExecuteQuery
command should ideally return an IEnumerable<T>
depending on what type of object the query results map to. The problem is that I cannot know what type this would be and therefore I would rather return a IEnumerable<dynamic>
type.
This is all good so far except that I want the dynamic objects properties to be the same as the columns being queried for but I cannot find anyway to assign this, I currently have all the column names in an array col[] e.g.
dynamic obj = new {} as dynamic;
for(int i = 0; i < col.Length; i++){
//say col[i] == 'id', I want obj.id = someValue
obj.? = someValue; ???
}
I hope this is clear. I hope it's not impossible!
p.s. I am writing this for WP7 so my options are severely limited, it might be good to keep this in mind.
Thanks for you help.