Accepted answer

You can do this: join the two collections and then specify how to convert to dictionary

                                 document => document.DocumentId,
                                 tDoc => tDoc.targetDocument,
                                 (document, tDoc) => new 
                                     Key = document.DocumentId, 
                                     Value = tDoc.DocumentId 
                            .ToDictionary(item => item.Key,
                                          item => item.Value);

Take note that if the join will result with 2 "records" for the same document.DocumentId it will throw a ArgumentException: An item with the same key has already been added.

If that might happen then think of:

  1. Saving it as a LookUp
  2. Saving it as a Dictionary<int,IEnumerable<int>>

For differences between the two check this

Related Query

More Query from same tag