Featured post
Dynamic Object .NET -
i facing interesting problem right now. know not pretty have cope anyway.
i calling webservice returns (array of string) (by index)
0 - table name ("employees")
1 - list of fields returned ("id, name, birthdate")
2 - first field value ("1")
3 - second field value ("bobby")
4 - third field value ("1970-01-01")
what accomplish create object name after index 0, having strings in index 1 being properties , feed them proper value.
what best way accomplish this? have started reading expandoobject before going far hear take on this.
regards
edit: have quite few different tables fetch data from, causing me problem.
it depends on use-case doubt dynamic
way go here. have name-value
collection so:
class result { dictionary<string, string> values = new dictionary<string, string>(); public string this[string name] { { return this.values[name]; } set { this.values[name] = value; } } // details }
then can populate values webservice , query values saying
result result = populateresultfromwebservice(); string id = result["id"];
etc. if knew types make indexer of type object
instead , parse values appropriate type , store them typed objects.
the issue dynamic
if names of fields unknown, how possibly going write code utilizes fields?
edit: have quite few different tables fetch data from, causing me problem.
dude, name-value collection day every day.
- Get link
- X
- Other Apps
Comments
Post a Comment