Getting a list of objects from mongodb with a filter

I am rather new to c# and MongoDb in particular. I have a method GetAllTickets() that returns a List<Ticket> with all entries of a MongoDb collection called "tickets". I want to be able to only get the entries with a certain filter from the collection in a different method called GetTicketsWithStatus(Status status) (where Status is an enum). How can I do this?

I have tried List<Ticket> tickets = collectionOfTickets.Find(x => x.ticketStatus == status).ToList<Ticket>(); (where collectionOfTickets is an IMongoCollection<Ticket> but that doesnt get any objects in the List. Any help will be appreciated.

P.S.: GetAllTickets() uses List<Ticket> tickets = collectionOfTickets.AsQueryable().ToList<Ticket>(); and it fills in the List properly. It's only when I try to use a filter that everything breaks and the list is not filled in.



Comments

Popular posts from this blog

Spring Elasticsearch Operations

Object oriented programming concepts (OOPs)

Network Error and Timeout on Authorize.net JS