So Basically I have this string which looks like query string "key1=value1&key2=value2"
(or maybe JSON
I have not decided it yet). so basically I want to convert this string Into an object and then enumerate through its properties (or fields) with reflection. I have already seen something called ExpandoObject
but in my case that won't help out, because I cannot enumerate through it's properties, and by that I mean the my properties, like .Key1
and .Key2
(from the string above) with reflection (or may be It is possible and I am doing something wrong). Anyway, any help and suggestion would be appreciated.
EDIT:
the Thing i want to achieve is this. I have an object than I need to store that object in db some have, as a string I gave example above and after that I need to recreate that object again from that string. (just to have the same properties of fields that the object I saved had)
So I have this one method which can be called directly or indirectly. If I call it directly I can create the object which is passed to this method (SomeParamsObject
) set it's propertioes and than pass it to the method, If called indirectly I am passing some other object to the other method which is calling that final method. to the first method I am passing some other objects and plus one anonymus object whichs properties are then merged with SomeParamsObject
(create inside of the first method by some other objects passed to it) and is passed to the final method. I also need to store this anonymus object somewhere in DB because the call may repeat from the other module of the code, so that's why I need to reconstruct it, To change all this to some KeyValue
collection, it would probably take me 4-5 days because this method is really called from bunch of modules of my code.