-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWrite.cs
35 lines (31 loc) · 888 Bytes
/
Write.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
25
26
27
28
29
30
31
32
33
34
35
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDBCRUD.Models;
namespace MongoDBCRUD
{
public class Write
{
public static void InsertByObjectModel(IMongoCollection<User> collection)
{
var newUser = new User
{
FirstName = "Jack",
LastName = "Smith",
Email = "jacksmith@123.com",
Address = "Somewhere"
};
collection.InsertOne(newUser);
}
public static void InsertByBsonDocument(IMongoCollection<BsonDocument> collection)
{
var newUser = new User
{
FirstName = "Jim",
LastName = "Smith",
Email = "jimsmith@123.com",
Address = "Somewhere"
};
collection.InsertOne(newUser.ToBsonDocument());
}
}
}