forked from jellyfin/jellyfin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJellyfinDbContext.cs
198 lines (138 loc) · 6.56 KB
/
JellyfinDbContext.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
using System;
using System.Linq;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Entities.Security;
using Jellyfin.Data.Interfaces;
using Microsoft.EntityFrameworkCore;
namespace Jellyfin.Server.Implementations;
/// <inheritdoc/>
public class JellyfinDbContext : DbContext
{
/// <summary>
/// Initializes a new instance of the <see cref="JellyfinDbContext"/> class.
/// </summary>
/// <param name="options">The database context options.</param>
public JellyfinDbContext(DbContextOptions<JellyfinDbContext> options) : base(options)
{
}
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the access schedules.
/// </summary>
public DbSet<AccessSchedule> AccessSchedules => Set<AccessSchedule>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the activity logs.
/// </summary>
public DbSet<ActivityLog> ActivityLogs => Set<ActivityLog>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the API keys.
/// </summary>
public DbSet<ApiKey> ApiKeys => Set<ApiKey>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the devices.
/// </summary>
public DbSet<Device> Devices => Set<Device>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the device options.
/// </summary>
public DbSet<DeviceOptions> DeviceOptions => Set<DeviceOptions>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the display preferences.
/// </summary>
public DbSet<DisplayPreferences> DisplayPreferences => Set<DisplayPreferences>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the image infos.
/// </summary>
public DbSet<ImageInfo> ImageInfos => Set<ImageInfo>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the item display preferences.
/// </summary>
public DbSet<ItemDisplayPreferences> ItemDisplayPreferences => Set<ItemDisplayPreferences>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the custom item display preferences.
/// </summary>
public DbSet<CustomItemDisplayPreferences> CustomItemDisplayPreferences => Set<CustomItemDisplayPreferences>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the permissions.
/// </summary>
public DbSet<Permission> Permissions => Set<Permission>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the preferences.
/// </summary>
public DbSet<Preference> Preferences => Set<Preference>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the users.
/// </summary>
public DbSet<User> Users => Set<User>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the trickplay metadata.
/// </summary>
public DbSet<TrickplayInfo> TrickplayInfos => Set<TrickplayInfo>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the media segments.
/// </summary>
public DbSet<MediaSegment> MediaSegments => Set<MediaSegment>();
/*public DbSet<Artwork> Artwork => Set<Artwork>();
public DbSet<Book> Books => Set<Book>();
public DbSet<BookMetadata> BookMetadata => Set<BookMetadata>();
public DbSet<Chapter> Chapters => Set<Chapter>();
public DbSet<Collection> Collections => Set<Collection>();
public DbSet<CollectionItem> CollectionItems => Set<CollectionItem>();
public DbSet<Company> Companies => Set<Company>();
public DbSet<CompanyMetadata> CompanyMetadata => Set<CompanyMetadata>();
public DbSet<CustomItem> CustomItems => Set<CustomItem>();
public DbSet<CustomItemMetadata> CustomItemMetadata => Set<CustomItemMetadata>();
public DbSet<Episode> Episodes => Set<Episode>();
public DbSet<EpisodeMetadata> EpisodeMetadata => Set<EpisodeMetadata>();
public DbSet<Genre> Genres => Set<Genre>();
public DbSet<Group> Groups => Set<Groups>();
public DbSet<Library> Libraries => Set<Library>();
public DbSet<LibraryItem> LibraryItems => Set<LibraryItems>();
public DbSet<LibraryRoot> LibraryRoot => Set<LibraryRoot>();
public DbSet<MediaFile> MediaFiles => Set<MediaFiles>();
public DbSet<MediaFileStream> MediaFileStream => Set<MediaFileStream>();
public DbSet<Metadata> Metadata => Set<Metadata>();
public DbSet<MetadataProvider> MetadataProviders => Set<MetadataProvider>();
public DbSet<MetadataProviderId> MetadataProviderIds => Set<MetadataProviderId>();
public DbSet<Movie> Movies => Set<Movie>();
public DbSet<MovieMetadata> MovieMetadata => Set<MovieMetadata>();
public DbSet<MusicAlbum> MusicAlbums => Set<MusicAlbum>();
public DbSet<MusicAlbumMetadata> MusicAlbumMetadata => Set<MusicAlbumMetadata>();
public DbSet<Person> People => Set<Person>();
public DbSet<PersonRole> PersonRoles => Set<PersonRole>();
public DbSet<Photo> Photo => Set<Photo>();
public DbSet<PhotoMetadata> PhotoMetadata => Set<PhotoMetadata>();
public DbSet<ProviderMapping> ProviderMappings => Set<ProviderMapping>();
public DbSet<Rating> Ratings => Set<Rating>();
/// <summary>
/// Repository for global::Jellyfin.Data.Entities.RatingSource - This is the entity to
/// store review ratings, not age ratings.
/// </summary>
public DbSet<RatingSource> RatingSources => Set<RatingSource>();
public DbSet<Release> Releases => Set<Release>();
public DbSet<Season> Seasons => Set<Season>();
public DbSet<SeasonMetadata> SeasonMetadata => Set<SeasonMetadata>();
public DbSet<Series> Series => Set<Series>();
public DbSet<SeriesMetadata> SeriesMetadata => Set<SeriesMetadata();
public DbSet<Track> Tracks => Set<Track>();
public DbSet<TrackMetadata> TrackMetadata => Set<TrackMetadata>();*/
/// <inheritdoc/>
public override int SaveChanges()
{
foreach (var saveEntity in ChangeTracker.Entries()
.Where(e => e.State == EntityState.Modified)
.Select(entry => entry.Entity)
.OfType<IHasConcurrencyToken>())
{
saveEntity.OnSavingChanges();
}
return base.SaveChanges();
}
/// <inheritdoc />
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.SetDefaultDateTimeKind(DateTimeKind.Utc);
base.OnModelCreating(modelBuilder);
// Configuration for each entity is in it's own class inside 'ModelConfiguration'.
modelBuilder.ApplyConfigurationsFromAssembly(typeof(JellyfinDbContext).Assembly);
}
}