title: Value cannot be null, parameter name: source
body: <p>I am sending collection of objects to my viewmodel like this</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>SoundsViewModel model = new SoundsViewModel(sound, AllGroups());
  </code></pre>
  
  <p><strong>ViewModel</strong></p>
  
  <pre><code>public SoundsViewModel(sound, List&lt;LocationGroup&gt; allGroups)
          {
              ....
  
              Groups = new List&lt;SoundLocationGroupViewModel&gt;();
              if (allGroups !=null)
              {
                  foreach (var item in allGroups)
                  {
                      var i = (from r in sound.LocationGroups where r.Id == item.Id select r).FirstOrDefault();
                      Groups.Add(new SoundLocationGroupViewModel() { LocationGroupId = item.Id, LocationGroupName = item.Name, IsInLocationGroup = (i != null) });
                  } 
              }
          }
  </code></pre>
  
  <p><strong>Error message is</strong></p>
  
  <pre><code>Value cannot be null.
  Parameter name: source
  
   var i = (from r in sound.LocationGroups where r.Id == item.Id select r).FirstOrDefault();
  </code></pre>
  
  <p>Obviously this message seems to be perfect and clear in describe situation but in debbuging I'm getting allGroups collection populated and properly received on the viewmodel. </p>
  
  <p>Any ideas, it's late and would really appreciate if someone suggest me a hint how to fix this in tommorow morning cofee. </p>
  
  <p>Thanks</p>
  
  <p>Update:
  Now it's passed.</p>
  
  <pre><code>foreach (var item in allGroups)
   {
      if(sound.LocationGroups !=null)
      {
       var i = (from r in sound.LocationGroups where r.Id == item.Id select r).FirstOrDefault();
       Groups.Add(new SoundLocationGroupViewModel() { LocationGroupId = item.Id, LocationGroupName = item.Name, IsInLocationGroup = (i != null) });
      }
  </code></pre>
  
  <p>} </p>