title: How to join MongoDB collection with string[] on collection with string using Linq
body: <p>I am trying to join two collections. I managed to join the two properly where the joining parts are equivalent in type - but that's not the goal. The difficulty occurs since i have a list of strings (id's) in one of the collections, and i want to replace each string in that list with an object of the other collection which is a collection of users defined as:</p>
  
  <pre><code>public string name { get; set; }
  public string email { get; set; }
  public string _id { get; set; }
  public bool IsDeleted { get; set; }
  </code></pre>
  
  <p>I have two types of meetings where i want to insert the users to the one replacing the strings hence it's a DTO.</p>
  
  <pre><code>public class MeetingBase : ModelBase
      {
          public string createdBy { get; set; }
          public string facilitator { get; set; }
          public string topic { get; set; }
          public string address { get; set; }
          public string city { get; set; }
          public string country { get; set; }
          public int RoomNumber { get; set; }
          public DateTime meetingDate { get; set; }
  
      }
  
  public class Meeting : MeetingBase
      {
          public List&lt;string&gt; attendees { get; set; }
      }
  
  public class MeetingDTO : MeetingBase
      {
          public List&lt;User&gt; attendees { get; set; }
      }
  </code></pre>
  
  <p>As said, i want to join the collection og <code>Meeting</code> with the collection of <code>users</code>, resulting in a collection of <code>MeetingDTO</code>'s</p>
  
  <p>So far, my best attempt is this: </p>
  
  <pre><code>public async Task&lt;List&lt;MeetingDTO&gt;&gt; getMeetingDtos(string userid)
          {
              var userCollection = _userDataManager.GetDataContext().MongoCollection;
              var meetingCollection = _meetingDataManager.GetDataContext().MongoCollection;
  
              var query = from m in meetingCollection.AsQueryable()
                  where (m.createdBy == userid)
                  from attendee in m.attendees
                  join u in userCollection.AsQueryable() on attendee equals u._id into meetingusers
                  select new MeetingDTO()
                  {
                      _id = m._id,
                      IsDeleted = m.IsDeleted,
                      attendees = meetingusers.ToList(),
                      address = m.address,
                      city = m.city,
                      country = m.country,
                      createdBy = m.createdBy,
                      facilitator = m.facilitator,
                      meetingDate = m.meetingDate,
                      RoomNumber = m.RoomNumber,
                      topic = m.topic
  
                  };
  
              var result = query.ToList();
              return result;
          }
  </code></pre>
  
  <p>However, this attempt gives the following run-time exception <code>System.NotSupportedException: '$project or $group does not support {document}.'
  </code></p>