-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModel.cs
113 lines (100 loc) · 3.53 KB
/
Model.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
namespace GraphQL.Benchmarks
{
public class StarWarsContext : DbContext
{
public DbSet<Human> Humans { get; set; }
public DbSet<Droid> Droids { get; set; }
public DbSet<Friendship> Friendships { get; set; }
public DbSet<Episode> Episodes { get; set; }
public DbSet<DroidAppearance> DroidAppearances { get; set; }
public DbSet<HumanAppearance> HumanAppearances { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder builder)
{
// builder.UseInMemoryDatabase();
builder.UseSqlite("Data Source=database.db");
}
}
public interface INode
{
int Id { get; }
}
public interface ICharacter
{
string Name { get; set; }
List<Friendship> Friendships { get; set; }
}
public class Human : ICharacter, INode
{
int INode.Id => HumanId;
public int HumanId { get; set; }
public string Name { get; set; }
public string HomePlanet { get; set; }
public List<Friendship> Friendships { get; set; }
public List<HumanAppearance> Appearances { get; set; }
public override string ToString ()
{
return HumanId.ToString ();
}
}
public class Friendship
{
public int FriendshipId { get; set; }
public int HumanId { get; set; }
public int DroidId { get; set; }
public Human Human { get; set; }
public Droid Droid { get; set; }
}
public class Droid : ICharacter, INode
{
int INode.Id => DroidId;
public int DroidId { get; set; }
public string Name { get; set; }
public string PrimaryFunction { get; set; }
public List<Friendship> Friendships { get; set; }
public List<DroidAppearance> Appearances { get; set; }
public override string ToString () {
return DroidId.ToString ();
}
}
public interface ICharacterAppearance
{
int EpisodeId { get; }
Episode Episode { get; }
int CharacterId { get; }
ICharacter Character { get; }
}
public class DroidAppearance : ICharacterAppearance, INode
{
int INode.Id => DroidAppearanceId;
public int DroidAppearanceId { get; set; }
public int EpisodeId { get; set; }
public Episode Episode { get; set; }
public int DroidId { get; set; }
public Droid Droid { get; set; }
int ICharacterAppearance.CharacterId => DroidId;
ICharacter ICharacterAppearance.Character => Droid;
}
public class HumanAppearance : ICharacterAppearance, INode
{
int INode.Id => HumanAppearanceId;
public int HumanAppearanceId { get; set; }
public int EpisodeId { get; set; }
public Episode Episode { get; set; }
public int HumanId { get; set; }
public Human Human { get; set; }
int ICharacterAppearance.CharacterId => HumanId;
ICharacter ICharacterAppearance.Character => Human;
}
public class Episode : INode
{
int INode.Id => EpisodeId;
public int EpisodeId { get; set; }
public string Name { get; set; }
public string Year { get; set; }
public List<DroidAppearance> DroidAppearances { get; set; }
public List<HumanAppearance> HumanAppearances { get; set; }
}
}