خرید بک لینک

Vote count: 0

I'm new at using mongoDb with .net Now I'm using C3 mongoDb Driver and I'm mapping my collection to my own C# class. when I query to get a specific document by Title Attribute the result is 3 items in the list each with different Id but the same data.

here's my C# code

class Program
{
    static void Main(string[] args)
    {

        MongoClient client = new MongoClient("mongodb://localhost:27017");
        IMongoDatabase database = client.GetDatabase("test");

        IMongoCollection<Book> books = database.GetCollection<Book>("books");

        var filter = Builders<Book>.Filter.Where(x => x.Title == "The Fifth Discipline");

        var list = books.Find(filter).ToList();

        foreach (var s in list)
        {
            Console.WriteLine(s.Id);
            Console.WriteLine(s.Title);
        }

        Console.ReadKey();
    }
}

public class Book
{
    public ObjectId Id { get; set; }
    public string Title { get; set; }
    public string Publisher { get; set; }
    public string Description { get; set; }
    public List<string> Authors { get; set; }
}

And the result on the Console is like this

enter image description here

asked 43 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 12 تير 1395 ساعت: 11:29

صفحه بندی