-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabaseManager.cs
More file actions
47 lines (43 loc) · 1.08 KB
/
DatabaseManager.cs
File metadata and controls
47 lines (43 loc) · 1.08 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
using MongoDB.Bson.IO;
using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.IdGenerators;
using MongoDB.Bson.Serialization.Options;
using MongoDB.Bson.Serialization.Serializers;
using MongoDB.Driver.Wrappers;
public class Movie
{
public BsonObjectId Id { get; set; }
public string Title { get; set; }
public string Year { get; set; }
public List<string> Actors { get; set; }
public void AddActor(string actor)
{
if (Actors == null)
{
Actors = new List<string>();
}
Actors.Add(actor);
}
}
public class DatabaseManager
{
private MongoServer server;
private MongoDatabase choicesDatabase;
public DatabaseManager()
{
Connect();
InsertData();
}
private void Connect()
{
server = MongoServer.Create();
moviesDatabase = server.GetDatabase("choices_db");
}
}