title: LINQ grouping in object
body: <p>I have two classes</p>
  
  <pre><code>public class MyObjects{
    public bool Active {get; set;}
    public List&lt;OtherObject&gt; OtherObjects {get; set;}
  }
  
  public class OtherObject {
    public int Id {get; set;}
    public bool Enabled {get; set;}
    public string Address {get; set;}
    public string Name {get; set;}
  }
  </code></pre>
  
  <p>My current result is </p>
  
  <pre><code>MyObject { Active = true; }, 
  OtherObjects: [OtherObject: { Id: 1, Name: 'First'}, 
  OtherObject{Id: 2, Name: 'First'}, 
  OtherObject{Id: 3, Name: 'Second'}];
  </code></pre>
  
  <p>I want to group them by <code>Name</code> so I would still have <code>Active</code> property and those <code>OtherObjects</code> inside would be grouped by <code>OtherObject</code> <code>Name</code> property. Is it possible to do so only using LINQ?</p>
  
  <p><strong>EDIT:</strong>
  Final result should be json, that I will use in angular, so it should be something like this:</p>
  
  <pre><code>{
    ""Active"": true,
    ""OtherObjects"": [
      {
        ""ObjectName"": ""Second"",
        ""ObjectOtherProperties"": [
          {
            ""Id"": 1,
            ""Enabled"": false
          },
          {
            ""Id"": 2,
            ""Enabled"": true
          }
        ],
        ""ObjectName"": ""Second"",
        ""ObjectOtherProperties"": [
          {
            ""Id"": 1,
            ""Enabled"": false
          }
        ],
      ]
    }
  }
  </code></pre>
  
  <p>Any suggestions how to achieve this? Maybe I must make other classes and somehow map them by grouping?</p>