LINQ to JSON and SelectMany

Feb 26, 2009 at 12:31 PM
hi!

I just tried to create a SelectMany LINQ Statement but can't compile it. What I try to do is something like that:

My JSON string looks like this:

{
  'ID' : 4711,
  'Name' : 'Test',
  'Tests' : [
    {
      'ID' : 1,
      'Value' : 'foo',

    },
    {
      'ID' : 1,
      'Value' : 'bar',

    }
  ]
}

And my Code is something like that:

JObject test = JObject.Parse(json);

var results = from p in test
              from t in p["Tests"]
              select new {
                 Test = p.Value<string>("Name"),
                 TestCount = t.Count
              };

I must say, that I'm not very familar with LINQ, so I used the "101 LINQ Statements" from MS as reference (http://msdn.microsoft.com/en-us/vcsharp/aa336758.aspx#SelectManyMultiplefrom).
Am I doing something obviously wrong, or isn't SelectMany Supported by the JSON.NET LINQ api?