title: Set and Get a collection in C#
body: <p>I have two classes: Group and Item. </p>
  
  <pre><code>public class Group
      {
          public string Name{ get; set; }
          public List&lt;Item&gt; ItemList { get; set; }
      }
  </code></pre>
  
  <p>And then Item</p>
  
  <pre><code>public class Item
      {
          public int ID{ get; set; }
          public string Name{ get; set; }
          public string Description{ get; set; }
          public Group ItemGroup {get;set;}       
        }
  </code></pre>
  
  <p>Each group show have a set of items.</p>
  
  <p>The following code is meant to get the list of items of a particular group, and it works when the ItemGroup in the Items class is set to type string, but not as a type Group.</p>
  
  <pre><code> public IEnumerable&lt;Item&gt; GetItemByGroup(string group)
   {
    return repository.GetAllItems().Where(
                  p =&gt; string.Equals(p.ItemGroup, group, StringComparison.OrdinalIgnoreCase));
   }
  </code></pre>
  
  <p>How to change the code to get the list of items in a group by its <code>Name</code> property which is set in the Group class.</p>
  
  <p>And how do I set a list/collection of Items in the Group class</p>