-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathObjectModelsAndSchemas.cs
50 lines (40 loc) · 1 KB
/
ObjectModelsAndSchemas.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using MongoDB.Bson;
using Realms;
namespace Examples
{
// Used by 3 tests in Objects.cs
// :snippet-start: dog_class
// :replace-start: {
// "terms": {
// "Dog_OMAS": "Dog" }
// }
public partial class Dog_OMAS : IRealmObject
{
[PrimaryKey]
[MapTo("_id")]
public ObjectId Id { get; set; }
[Required]
public string Name { get; set; }
public int Age { get; set; }
public string Breed { get; set; }
public IList<Person> Owners { get; }
}
public partial class Person : IRealmObject
{
[PrimaryKey]
[MapTo("_id")]
public ObjectId Id { get; set; }
[Required]
public string Name { get; set; }
// etc...
/* To add items to the IList<T>:
var dog = new Dog();
var caleb = new Person { Name = "Caleb" };
dog.Owners.Add(caleb);
*/
}
// :replace-end:
// :snippet-end:
}