using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.Serialization.Options; using MongoDB.Driver; using MongoDB.Driver.Linq; RunTest(LinqProvider.V2); RunTest(LinqProvider.V3); void RunTest(LinqProvider prov) { try { var settings = MongoClientSettings.FromConnectionString("mongodb://localhost:27017"); settings.LinqProvider = prov; var client = new MongoClient(settings); var db = client.GetDatabase("test"); var coll = db.GetCollection("my_collection"); var result = coll .AsQueryable() .Select(x => new { Strings = x.DictData.Select(y => y.Value), }) .ToArray(); Console.WriteLine($"Works for provider version {prov} (returned items: {result.Length})"); foreach (var item in result) Console.WriteLine(string.Join("; ", item.Strings)); } catch (Exception ex) { var color = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Error for provider version {prov}: {ex.Message}"); Console.ForegroundColor = color; } Console.WriteLine("-------------------------------------------"); } class MyDocument { [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)] public string Id { get; set; } public string Group { get; set; } [BsonDictionaryOptions(DictionaryRepresentation.ArrayOfDocuments)] public Dictionary DictData { get; set; } = new Dictionary(); }