using System.Collections.Generic;
public int Id { get; set; }
public int Id { get; set; }
public Document Document { get; set; }
public static void Main()
var documentReferences = new[] { 1, 2, 3, 4, 5 }.Select(i => new DocumentReference { Id = i });
var documents = new Dictionary<int, Document>
{ 1, new Document { Id = 1 } },
{ 4, new Document { Id = 4 } }
foreach (var docRef in documentReferences)
if (!documents.TryGetValue(docRef.Id, out Document doc))
Console.WriteLine($"Matched document references: {documentReferences.Count(d => d.Document != null)}");