-
Notifications
You must be signed in to change notification settings - Fork 0
/
Read.cs
24 lines (22 loc) · 726 Bytes
/
Read.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDBCRUD.Models;
using System.Collections.Generic;
namespace MongoDBCRUD
{
public static class Read
{
public static List<User> GetByObjectModel(IMongoCollection<User> collection)
{
var filter = Builders<User>.Filter;
var query = filter.Eq(x => x.FirstName, "John");
return collection.Find(query).ToList();
}
public static List<BsonDocument> GetByBsonDocument(IMongoCollection<BsonDocument> collection)
{
var filter = Builders<BsonDocument>.Filter;
var query = filter.Eq("FirstName", "John");
return collection.Find(query).ToList();
}
}
}