Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8320675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:44:16+00:00 2026-06-08T22:44:16+00:00

namespace WebApplication1.Site { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender,

  • 0
    namespace WebApplication1.Site
{
public partial class WebForm1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {


        var accessToken = "" // Token
        var client = new FacebookClient(accessToken);
        dynamic myInfo = client.Get("me/friends", new { fields = "name,id,work" });

        foreach (dynamic friend in myInfo)
        {
            foreach (dynamic work in friend.work ?? new[] { new { employer = new { name = string.Empty }, position = new { name = string.Empty } } })
                {
                    Response.Write("Employer: " + work.employer.name);
                }

        }


    }
}
}

I am getting the following error on line 21. I cannot figure out what is causing it.

‘System.Collections.Generic.KeyValuePair’ does not contain a definition for ‘work’

Sample JSON Return from the Facebook GraphAPI. This is only the first three friends. There are closer to 4000 friends I am parsing, obviously this gives some context for the structure of the data:

    {
      "data": [
{
  "name": "Mia xxx", 
  "id": "11381", 
  "work": [
    {
      "employer": {
        "id": "100982923276720", 
        "name": "New-York Historical Society"
      }, 
      "location": {
        "id": "108424279189115", 
        "name": "New York, New York"
      }
    }
  ]
}, 
{
  "name": "Leilah xxx", 
  "id": "1133"
}, 
{
  "name": "xxx, 
  "id": "1231", 
  "work": [
    {
      "employer": {
        "id": "104362369673437", 
        "name": "Bye Bye Liver: The Philadelphia Drinking Play"
      }, 
      "location": {
        "id": "101881036520836", 
        "name": "Philadelphia, Pennsylvania"
      }, 
      "position": {
        "id": "121113421241569", 
        "name": "Actress/Bartender"
      }, 
      "description": "A sketch comedy/improv show every Saturday night at Downey's on South & Front. Come thirsty!", 
      "start_date": "2011-09"
    }, 
    {
      "employer": {
        "id": "100952634348", 
        "name": "Act II Playhouse"
      }, 
      "location": {
        "id": "109249869093538", 
        "name": "Ambler, Pennsylvania"
      }, 
      "position": {
        "id": "125578900846788", 
        "name": "My Fair Lady"
      }, 
      "description": "11 actor version of the classic musical.", 
      "start_date": "0000-00"
    }, 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T22:44:19+00:00Added an answer on June 8, 2026 at 10:44 pm

    An alternative to relying on the dynamic is to capture and parse the JSON with JSON.net, it’s designed for querying json data and is really much safer than using dynamic

    http://json.codeplex.com/

    And deserializing into classes:

    http://dotnetbyexample.blogspot.ca/2012/02/json-deserialization-with-jsonnet-class.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using System; namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { public void
public class MessageHelper : System.Web.UI.MasterPage { public MessageHelper() { } public string Message {
hello i m doing a very simple Asp.net application project namespace WebApplication1 { public
using namespace std; class A { public: A() {} ~A() {} map<int, string*>& getMap()
The whole program in a web form of a .net web-application: namespace WebApplication1 {
Here's my binding source object: Public Class MyListObject Private _mylist As New ObservableCollection(Of String)
<Window x:Class=MyWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:src=clr-namespace:WpfApplication1 Title=ContactsSelector Height=300 Width=300> <Window.Content> <src:MyPage> <!--MyPage is a page
namespace MyOldService { public MyNewService.AddressList ToPrivateAddressList() { MyNewService.AddressList privAddrList = new MyNewService.AddressList(); privAddrList.creator =
After namespace , class , struct , enum , for , foreach , while
If I have a namespace like: namespace MyApp.Providers { using System; using System.Collections.Generic; using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.