Witam, w jaki sposób wyświetlić dane z kolekcji po wykonaniu zapytania.
Przykładowe klasy.
public class User
{
[BsonId]
public ObjectId Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public IList<Car> CarName { get; set; }
}
public class Car
{
public string Brand { get; set; }
}
// połączenie z bazą MongoDb
var list = userCollection.Find(x => x.Age > 30 && x.CarName.Any(t => t.Brand == "Kia" || t.Brand == "Opel")).ToList();
foreach (var item in list)
{
Console.WriteLine(item.Name + " " + item.Age + " " + item.CarName.ToString()); // jak wyświetlić markę samochodu ?
}