-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (47 loc) · 1.79 KB
/
Copy pathProgram.cs
File metadata and controls
57 lines (47 loc) · 1.79 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
48
49
50
51
52
53
54
55
56
57
using System;
namespace TestingDotnetCoreWithMongoDB
{
class Program
{
static void Main(string[] args)
{
MongoCRUD db = new MongoCRUD("DemoMongoDB");
//PersonModel person = new PersonModel
//{
// FirstName = "Rob",
// LastName = "RobsLastname",
// PrimaryAddress = new AddressModel
// {
// Address = "Somaddress 99-95",
// City = "RIX",
// ZipCode = "LV102030"
// }
//};
//db.InsertRecord("Users", person);//{ FirstName = "HumansName", LastName = "HumansSurname" });
// from users table
//var records = db.LoadRecords<PersonModel>("Users");
//foreach (var rec in records)
//{
// Console.WriteLine($"{ rec.ID }: {rec.FirstName} {rec.LastName}");
// if (rec.PrimaryAddress != null)
// {
// Console.WriteLine(rec.PrimaryAddress.City);
// }
// Console.WriteLine();
//}
var records = db.LoadRecords<NameModel>("Users");
foreach (var rec in records)
{
Console.WriteLine($"{rec.FirstName} {rec.LastName}");
Console.WriteLine();
}
//var oneRecord = db.LoadRecordById<PersonModel>("Users", new Guid("da39e7d4-ce97-48d6-a6e6-8b3d022046c6"));
//oneRecord.DateOfBirth = new DateTime(1942, 11, 13, 0, 0, 0, DateTimeKind.Utc);
//upserting
//db.UpsertRecord("Users", oneRecord.Id, oneRecord);
// db.DeleteRecord<PersonModel>("Users", oneRecord.Id);
Console.ReadLine();
//1:00:00
}
}
}