开发者

How to convert from object to something more readable like IDictionary

开发者 https://www.devze.com 2023-01-23 03:26 出处:网络
I\'m happy to see 4.0.2 has support for .net 3.5, however there are no samples to understand how to use it, without dynamic k开发者_如何学JAVAeyword.

I'm happy to see 4.0.2 has support for .net 3.5, however there are no samples to understand how to use it, without dynamic k开发者_如何学JAVAeyword.

For example I have

FacebookApp app = new FacebookApp(GetSettings());                

object result = app.Fql(string.Format("SELECT id,name,type FROM profile WHERE id={0}", strID));

What is the simplest way to convert result to Dictionary or something more useful ?


Found it, not as sexy as dynamic 4.0, but it works:

FacebookApp app = new FacebookApp(GetSettings());
var result = app.Fql(string.Format("SELECT id,name,type FROM profile WHERE id={0}", strID));
var dicResult = ((JsonArray)result)[0] as IDictionary<string, object>;

Hope it will help another 3.5 developer


a Dictionary is generaly a 2 item list.

Dictionary(TKey, TValue)

Under the circumstances from your sql you'll be getting back 3 fields in your result, and unless i'm missing something it should only be 1 result set.

a single object with 3 parameters should be sufficent.

Now if your returning multiple lines with only two fields... now thats a different story.

0

精彩评论

暂无评论...
验证码 换一张
取 消