Updated code to correct build errors for Jelyfin.Data and Jellyfin.Database.Implementations

This commit is contained in:
2026-02-19 15:51:56 -05:00
parent f47555f2aa
commit d5fdbec943
317 changed files with 17235 additions and 3473 deletions
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Jellyfin.CodeAnalysis")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+036953f3ffd782d56040af1332c53c54c7107be2")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f47555f2aa4eff7dcc5c5ef5bbda374f292f0638")]
[assembly: System.Reflection.AssemblyProductAttribute("Jellyfin.CodeAnalysis")]
[assembly: System.Reflection.AssemblyTitleAttribute("Jellyfin.CodeAnalysis")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -1 +1 @@
14abb783c55dca9d506ea58b2fb4e83cf46869fbb125fd5d419b7cd5ec04579a
cfe4822f334685403d8dd28c9794902cf41ac16cf3fdae734ed53b2348acf886
@@ -1 +1 @@
925762113528dbfe64b2ae859ceacd4178e352a947de363b76e06cbd504b0ecf
e7c17426fec14bd402397d7c8b6303a56fe39a7ababbc3fc41dcceedc7dc82f3
@@ -10,3 +10,15 @@ C:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\bin\Debug\netstandard2.0\Je
C:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\bin\Debug\netstandard2.0\Jellyfin.CodeAnalysis.xml
C:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\obj\Debug\netstandard2.0\Jellyfin.CodeAnalysis.dll
C:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\obj\Debug\netstandard2.0\Jellyfin.CodeAnalysis.pdb
E:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\bin\Debug\netstandard2.0\Jellyfin.CodeAnalysis.deps.json
E:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\bin\Debug\netstandard2.0\Jellyfin.CodeAnalysis.dll
E:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\bin\Debug\netstandard2.0\Jellyfin.CodeAnalysis.pdb
E:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\bin\Debug\netstandard2.0\Jellyfin.CodeAnalysis.xml
E:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\obj\Debug\netstandard2.0\Jellyfin.CodeAnalysis.csproj.AssemblyReference.cache
E:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\obj\Debug\netstandard2.0\Jellyfin.CodeAnalysis.GeneratedMSBuildEditorConfig.editorconfig
E:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\obj\Debug\netstandard2.0\Jellyfin.CodeAnalysis.AssemblyInfoInputs.cache
E:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\obj\Debug\netstandard2.0\Jellyfin.CodeAnalysis.AssemblyInfo.cs
E:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\obj\Debug\netstandard2.0\Jellyfin.CodeAnalysis.csproj.CoreCompileInputs.cache
E:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\obj\Debug\netstandard2.0\Jellyfin.CodeAnalysis.dll
E:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\obj\Debug\netstandard2.0\Jellyfin.CodeAnalysis.xml
E:\Projects\pgsql-jellyfin\src\Jellyfin.CodeAnalysis\obj\Debug\netstandard2.0\Jellyfin.CodeAnalysis.pdb
@@ -3,64 +3,64 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities
using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Serialization;
using Jellyfin.Database.Implementations.Enums;
// <summary>
// An entity representing a user's access schedule.
// </summary>
public class AccessSchedule
{
using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Serialization;
using Jellyfin.Database.Implementations.Enums;
/// <summary>
/// Initializes a new instance of the <see cref="AccessSchedule"/> class.
/// An entity representing a user's access schedule.
/// </summary>
/// <param name="dayOfWeek">The day of the week.</param>
/// <param name="startHour">The start hour.</param>
/// <param name="endHour">The end hour.</param>
/// <param name="userId">The associated user's id.</param>
public AccessSchedule(DynamicDayOfWeek dayOfWeek, double startHour, double endHour, Guid userId)
public class AccessSchedule
{
UserId = userId;
DayOfWeek = dayOfWeek;
StartHour = startHour;
EndHour = endHour;
/// <summary>
/// Initializes a new instance of the <see cref="AccessSchedule"/> class.
/// </summary>
/// <param name="dayOfWeek">The day of the week.</param>
/// <param name="startHour">The start hour.</param>
/// <param name="endHour">The end hour.</param>
/// <param name="userId">The associated user's id.</param>
public AccessSchedule(DynamicDayOfWeek dayOfWeek, double startHour, double endHour, Guid userId)
{
this.UserId = userId;
this.DayOfWeek = dayOfWeek;
this.StartHour = startHour;
this.EndHour = endHour;
}
/// <summary>
/// Gets the id of this instance.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[XmlIgnore]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id of the associated user.
/// </summary>
[XmlIgnore]
public Guid UserId { get; private set; }
/// <summary>
/// Gets or sets the day of week.
/// </summary>
/// <value>The day of week.</value>
public DynamicDayOfWeek DayOfWeek { get; set; }
/// <summary>
/// Gets or sets the start hour.
/// </summary>
/// <value>The start hour.</value>
public double StartHour { get; set; }
/// <summary>
/// Gets or sets the end hour.
/// </summary>
/// <value>The end hour.</value>
public double EndHour { get; set; }
}
/// <summary>
/// Gets the id of this instance.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[XmlIgnore]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id of the associated user.
/// </summary>
[XmlIgnore]
public Guid UserId { get; private set; }
/// <summary>
/// Gets or sets the day of week.
/// </summary>
/// <value>The day of week.</value>
public DynamicDayOfWeek DayOfWeek { get; set; }
/// <summary>
/// Gets or sets the start hour.
/// </summary>
/// <value>The start hour.</value>
public double StartHour { get; set; }
/// <summary>
/// Gets or sets the end hour.
/// </summary>
/// <value>The end hour.</value>
public double EndHour { get; set; }
}
@@ -2,125 +2,132 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace Jellyfin.Database.Implementations.Entities
#pragma warning disable CA1724 //The type name conflicts in whole or in part with the namespace name (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
using Microsoft.Extensions.Logging;
namespace Jellyfin.Database.Implementations.Entities
{
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
using Microsoft.Extensions.Logging;
/// <summary>
/// An entity referencing an activity log entry.
/// </summary>
public class ActivityLog : IHasConcurrencyToken
{
/// <summary>
/// Initializes a new instance of the <see cref="ActivityLog"/> class.
/// Public constructor with required data.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="type">The type.</param>
/// <param name="userId">The user id.</param>
public ActivityLog(string name, string type, Guid userId)
public class ActivityLog : IHasConcurrencyToken
{
ArgumentException.ThrowIfNullOrEmpty(name);
ArgumentException.ThrowIfNullOrEmpty(type);
/// <summary>
/// Initializes a new instance of the <see cref="ActivityLog"/> class.
/// Public constructor with required data.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="type">The type.</param>
/// <param name="userId">The user id.</param>
public ActivityLog(string name, string type, Guid userId)
{
ArgumentException.ThrowIfNullOrEmpty(name);
ArgumentException.ThrowIfNullOrEmpty(type);
Name = name;
Type = type;
UserId = userId;
DateCreated = DateTime.UtcNow;
LogSeverity = LogLevel.Information;
}
this.Name = name;
this.Type = type;
this.UserId = userId;
this.DateCreated = DateTime.UtcNow;
this.LogSeverity = LogLevel.Information;
}
/// <summary>
/// Gets the identity of this instance.
/// </summary>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the identity of this instance.
/// </summary>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Required, Max length = 512.
/// </remarks>
[MaxLength(512)]
[StringLength(512)]
public string Name { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Required, Max length = 512.
/// </remarks>
[MaxLength(512)]
[StringLength(512)]
public string Name { get; set; }
/// <summary>
/// Gets or sets the overview.
/// </summary>
/// <remarks>
/// Max length = 512.
/// </remarks>
[MaxLength(512)]
[StringLength(512)]
public string? Overview { get; set; }
/// <summary>
/// Gets or sets the overview.
/// </summary>
/// <remarks>
/// Max length = 512.
/// </remarks>
[MaxLength(512)]
[StringLength(512)]
public string? Overview { get; set; }
/// <summary>
/// Gets or sets the short overview.
/// </summary>
/// <remarks>
/// Max length = 512.
/// </remarks>
[MaxLength(512)]
[StringLength(512)]
public string? ShortOverview { get; set; }
/// <summary>
/// Gets or sets the short overview.
/// </summary>
/// <remarks>
/// Max length = 512.
/// </remarks>
[MaxLength(512)]
[StringLength(512)]
public string? ShortOverview { get; set; }
/// <summary>
/// Gets or sets the type.
/// </summary>
/// <remarks>
/// Required, Max length = 256.
/// </remarks>
[MaxLength(256)]
[StringLength(256)]
public string Type { get; set; }
/// <summary>
/// Gets or sets the type.
/// </summary>
/// <remarks>
/// Required, Max length = 256.
/// </remarks>
[MaxLength(256)]
[StringLength(256)]
public string Type { get; set; }
/// <summary>
/// Gets or sets the user id.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public Guid UserId { get; set; }
/// <summary>
/// Gets or sets the user id.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public Guid UserId { get; set; }
/// <summary>
/// Gets or sets the item id.
/// </summary>
/// <remarks>
/// Max length = 256.
/// </remarks>
[MaxLength(256)]
[StringLength(256)]
public string? ItemId { get; set; }
/// <summary>
/// Gets or sets the item id.
/// </summary>
/// <remarks>
/// Max length = 256.
/// </remarks>
[MaxLength(256)]
[StringLength(256)]
public string? ItemId { get; set; }
/// <summary>
/// Gets or sets the date created. This should be in UTC.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public DateTime DateCreated { get; set; }
/// <summary>
/// Gets or sets the date created. This should be in UTC.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public DateTime DateCreated { get; set; }
/// <summary>
/// Gets or sets the log severity. Default is <see cref="LogLevel.Trace"/>.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public LogLevel LogSeverity { get; set; }
/// <summary>
/// Gets or sets the log severity. Default is <see cref="LogLevel.Trace"/>.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public LogLevel LogSeverity { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets the concurrency token used for optimistic concurrency control.
/// </summary>
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <summary>
/// Updates the concurrency token before saving changes.
/// </summary>
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -6,6 +6,7 @@ namespace Jellyfin.Database.Implementations.Entities;
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CA2227 // Collection properties should be read only
#pragma warning disable SA1600 // Missing XML comment for publicly visible type or member
using System;
using System.Collections.Generic;
@@ -5,6 +5,9 @@
namespace Jellyfin.Database.Implementations.Entities;
#pragma warning disable CS1591
#pragma warning disable SA1600
#pragma warning disable SA1602
#pragma warning disable CA1720
public enum BaseItemExtraType
{
Unknown = 0,
@@ -18,5 +21,5 @@ public enum BaseItemExtraType
ThemeSong = 8,
ThemeVideo = 9,
Featurette = 10,
Short = 11
Short = 11,
}
@@ -3,81 +3,82 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
/// <summary>
/// An entity that represents a user's custom display preferences for a specific item.
/// </summary>
public class CustomItemDisplayPreferences
{
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
/// <summary>
/// Initializes a new instance of the <see cref="CustomItemDisplayPreferences"/> class.
/// An entity that represents a user's custom display preferences for a specific item.
/// </summary>
/// <param name="userId">The user id.</param>
/// <param name="itemId">The item id.</param>
/// <param name="client">The client.</param>
/// <param name="key">The preference key.</param>
/// <param name="value">The preference value.</param>
public CustomItemDisplayPreferences(Guid userId, Guid itemId, string client, string key, string? value)
public class CustomItemDisplayPreferences
{
UserId = userId;
ItemId = itemId;
Client = client;
Key = key;
Value = value;
/// <summary>
/// Initializes a new instance of the <see cref="CustomItemDisplayPreferences"/> class.
/// </summary>
/// <param name="userId">The user id.</param>
/// <param name="itemId">The item id.</param>
/// <param name="client">The client.</param>
/// <param name="key">The preference key.</param>
/// <param name="value">The preference value.</param>
public CustomItemDisplayPreferences(Guid userId, Guid itemId, string client, string key, string? value)
{
this.UserId = userId;
this.ItemId = itemId;
this.Client = client;
this.Key = key;
this.Value = value;
}
/// <summary>
/// Gets the Id.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the user Id.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public Guid UserId { get; set; }
/// <summary>
/// Gets or sets the id of the associated item.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public Guid ItemId { get; set; }
/// <summary>
/// Gets or sets the client string.
/// </summary>
/// <remarks>
/// Required. Max Length = 32.
/// </remarks>
[MaxLength(32)]
[StringLength(32)]
public string Client { get; set; }
/// <summary>
/// Gets or sets the preference key.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public string Key { get; set; }
/// <summary>
/// Gets or sets the preference value.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public string? Value { get; set; }
}
/// <summary>
/// Gets the Id.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the user Id.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public Guid UserId { get; set; }
/// <summary>
/// Gets or sets the id of the associated item.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public Guid ItemId { get; set; }
/// <summary>
/// Gets or sets the client string.
/// </summary>
/// <remarks>
/// Required. Max Length = 32.
/// </remarks>
[MaxLength(32)]
[StringLength(32)]
public string Client { get; set; }
/// <summary>
/// Gets or sets the preference key.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public string Key { get; set; }
/// <summary>
/// Gets or sets the preference value.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public string? Value { get; set; }
}
@@ -2,154 +2,155 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable CA1724 //The type name conflicts in whole or in part with the namespace name (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)
namespace Jellyfin.Database.Implementations.Entities
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
/// <summary>
/// An entity representing a user's display preferences.
/// </summary>
public class DisplayPreferences
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
/// <summary>
/// Initializes a new instance of the <see cref="DisplayPreferences"/> class.
/// An entity representing a user's display preferences.
/// </summary>
/// <param name="userId">The user's id.</param>
/// <param name="itemId">The item id.</param>
/// <param name="client">The client string.</param>
public DisplayPreferences(Guid userId, Guid itemId, string client)
public class DisplayPreferences
{
UserId = userId;
ItemId = itemId;
Client = client;
ShowSidebar = false;
ShowBackdrop = true;
SkipForwardLength = 30000;
SkipBackwardLength = 10000;
ScrollDirection = ScrollDirection.Horizontal;
ChromecastVersion = ChromecastVersion.Stable;
/// <summary>
/// Initializes a new instance of the <see cref="DisplayPreferences"/> class.
/// </summary>
/// <param name="userId">The user's id.</param>
/// <param name="itemId">The item id.</param>
/// <param name="client">The client string.</param>
public DisplayPreferences(Guid userId, Guid itemId, string client)
{
this.UserId = userId;
this.ItemId = itemId;
this.Client = client;
this.ShowSidebar = false;
this.ShowBackdrop = true;
this.SkipForwardLength = 30000;
this.SkipBackwardLength = 10000;
this.ScrollDirection = ScrollDirection.Horizontal;
this.ChromecastVersion = ChromecastVersion.Stable;
HomeSections = new HashSet<HomeSection>();
this.HomeSections = new HashSet<HomeSection>();
}
/// <summary>
/// Gets the Id.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the user Id.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public Guid UserId { get; set; }
/// <summary>
/// Gets or sets the id of the associated item.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public Guid ItemId { get; set; }
/// <summary>
/// Gets or sets the client string.
/// </summary>
/// <remarks>
/// Required. Max Length = 32.
/// </remarks>
[MaxLength(32)]
[StringLength(32)]
public string Client { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to show the sidebar.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool ShowSidebar { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to show the backdrop.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool ShowBackdrop { get; set; }
/// <summary>
/// Gets or sets the scroll direction.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public ScrollDirection ScrollDirection { get; set; }
/// <summary>
/// Gets or sets what the view should be indexed by.
/// </summary>
public IndexingKind? IndexBy { get; set; }
/// <summary>
/// Gets or sets the length of time to skip forwards, in milliseconds.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int SkipForwardLength { get; set; }
/// <summary>
/// Gets or sets the length of time to skip backwards, in milliseconds.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int SkipBackwardLength { get; set; }
/// <summary>
/// Gets or sets the Chromecast Version.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public ChromecastVersion ChromecastVersion { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the next video info overlay should be shown.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool EnableNextVideoInfoOverlay { get; set; }
/// <summary>
/// Gets or sets the dashboard theme.
/// </summary>
[MaxLength(32)]
[StringLength(32)]
public string? DashboardTheme { get; set; }
/// <summary>
/// Gets or sets the tv home screen.
/// </summary>
[MaxLength(32)]
[StringLength(32)]
public string? TvHome { get; set; }
/// <summary>
/// Gets the home sections.
/// </summary>
public virtual ICollection<HomeSection> HomeSections { get; private set; }
}
/// <summary>
/// Gets the Id.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the user Id.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public Guid UserId { get; set; }
/// <summary>
/// Gets or sets the id of the associated item.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public Guid ItemId { get; set; }
/// <summary>
/// Gets or sets the client string.
/// </summary>
/// <remarks>
/// Required. Max Length = 32.
/// </remarks>
[MaxLength(32)]
[StringLength(32)]
public string Client { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to show the sidebar.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool ShowSidebar { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to show the backdrop.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool ShowBackdrop { get; set; }
/// <summary>
/// Gets or sets the scroll direction.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public ScrollDirection ScrollDirection { get; set; }
/// <summary>
/// Gets or sets what the view should be indexed by.
/// </summary>
public IndexingKind? IndexBy { get; set; }
/// <summary>
/// Gets or sets the length of time to skip forwards, in milliseconds.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int SkipForwardLength { get; set; }
/// <summary>
/// Gets or sets the length of time to skip backwards, in milliseconds.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int SkipBackwardLength { get; set; }
/// <summary>
/// Gets or sets the Chromecast Version.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public ChromecastVersion ChromecastVersion { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the next video info overlay should be shown.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool EnableNextVideoInfoOverlay { get; set; }
/// <summary>
/// Gets or sets the dashboard theme.
/// </summary>
[MaxLength(32)]
[StringLength(32)]
public string? DashboardTheme { get; set; }
/// <summary>
/// Gets or sets the tv home screen.
/// </summary>
[MaxLength(32)]
[StringLength(32)]
public string? TvHome { get; set; }
/// <summary>
/// Gets the home sections.
/// </summary>
public virtual ICollection<HomeSection> HomeSections { get; private set; }
}
@@ -3,68 +3,68 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a group.
/// </summary>
public class Group : IHasPermissions, IHasConcurrencyToken
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Group"/> class.
/// An entity representing a group.
/// </summary>
/// <param name="name">The name of the group.</param>
public Group(string name)
public class Group : IHasPermissions, IHasConcurrencyToken
{
ArgumentException.ThrowIfNullOrEmpty(name);
/// <summary>
/// Initializes a new instance of the <see cref="Group"/> class.
/// </summary>
/// <param name="name">The name of the group.</param>
public Group(string name)
{
ArgumentException.ThrowIfNullOrEmpty(name);
Name = name;
Id = Guid.NewGuid();
this.Name = name;
this.Id = Guid.NewGuid();
Permissions = new HashSet<Permission>();
Preferences = new HashSet<Preference>();
}
this.Permissions = new HashSet<Permission>();
this.Preferences = new HashSet<Preference>();
}
/// <summary>
/// Gets the id of this group.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
public Guid Id { get; private set; }
/// <summary>
/// Gets the id of this group.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
public Guid Id { get; private set; }
/// <summary>
/// Gets or sets the group's name.
/// </summary>
/// <remarks>
/// Required, Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string Name { get; set; }
/// <summary>
/// Gets or sets the group's name.
/// </summary>
/// <remarks>
/// Required, Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string Name { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets a collection containing the group's permissions.
/// </summary>
public virtual ICollection<Permission> Permissions { get; private set; }
/// <summary>
/// Gets a collection containing the group's permissions.
/// </summary>
public virtual ICollection<Permission> Permissions { get; private set; }
/// <summary>
/// Gets a collection containing the group's preferences.
/// </summary>
public virtual ICollection<Preference> Preferences { get; private set; }
/// <summary>
/// Gets a collection containing the group's preferences.
/// </summary>
public virtual ICollection<Preference> Preferences { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -3,46 +3,46 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
/// <summary>
/// An entity representing a section on the user's home page.
/// </summary>
public class HomeSection
{
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity. Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
/// <summary>
/// Gets or sets the Id of the associated display preferences.
/// An entity representing a section on the user's home page.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int DisplayPreferencesId { get; set; }
public class HomeSection
{
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity. Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the order.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int Order { get; set; }
/// <summary>
/// Gets or sets the Id of the associated display preferences.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int DisplayPreferencesId { get; set; }
/// <summary>
/// Gets or sets the type.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public HomeSectionType Type { get; set; }
/// <summary>
/// Gets or sets the order.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int Order { get; set; }
/// <summary>
/// Gets or sets the type.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public HomeSectionType Type { get; set; }
}
}
@@ -3,55 +3,56 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
/// <summary>
/// An entity representing an image.
/// </summary>
public class ImageInfo
{
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
/// <summary>
/// Initializes a new instance of the <see cref="ImageInfo"/> class.
/// An entity representing an image.
/// </summary>
/// <param name="path">The path.</param>
public ImageInfo(string path)
public class ImageInfo
{
Path = path;
LastModified = DateTime.UtcNow;
/// <summary>
/// Initializes a new instance of the <see cref="ImageInfo"/> class.
/// </summary>
/// <param name="path">The path.</param>
public ImageInfo(string path)
{
this.Path = path;
this.LastModified = DateTime.UtcNow;
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the user id.
/// </summary>
public Guid? UserId { get; private set; }
/// <summary>
/// Gets or sets the path of the image.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
[MaxLength(512)]
[StringLength(512)]
public string Path { get; set; }
/// <summary>
/// Gets or sets the date last modified.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public DateTime LastModified { get; set; }
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the user id.
/// </summary>
public Guid? UserId { get; private set; }
/// <summary>
/// Gets or sets the path of the image.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
[MaxLength(512)]
[StringLength(512)]
public string Path { get; set; }
/// <summary>
/// Gets or sets the date last modified.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public DateTime LastModified { get; set; }
}
@@ -76,5 +76,5 @@ public enum ImageInfoImageType
/// <summary>
/// The user profile image.
/// </summary>
Profile = 12
Profile = 12,
}
@@ -3,13 +3,12 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
{
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
/// <summary>
/// An entity that represents a user's display preferences for a specific item.
/// </summary>
@@ -23,14 +22,14 @@ using Jellyfin.Database.Implementations.Enums;
/// <param name="client">The client.</param>
public ItemDisplayPreferences(Guid userId, Guid itemId, string client)
{
UserId = userId;
ItemId = itemId;
Client = client;
this.UserId = userId;
this.ItemId = itemId;
this.Client = client;
SortBy = "SortName";
SortOrder = SortOrder.Ascending;
RememberSorting = false;
RememberIndexing = false;
this.SortBy = "SortName";
this.SortOrder = SortOrder.Ascending;
this.RememberSorting = false;
this.RememberIndexing = false;
}
/// <summary>
@@ -3,67 +3,66 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing artwork.
/// </summary>
public class Artwork : IHasConcurrencyToken
{
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Artwork"/> class.
/// An entity representing artwork.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="kind">The kind of art.</param>
public Artwork(string path, ArtKind kind)
public class Artwork : IHasConcurrencyToken
{
ArgumentException.ThrowIfNullOrEmpty(path);
/// <summary>
/// Initializes a new instance of the <see cref="Artwork"/> class.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="kind">The kind of art.</param>
public Artwork(string path, ArtKind kind)
{
ArgumentException.ThrowIfNullOrEmpty(path);
Path = path;
Kind = kind;
}
this.Path = path;
this.Kind = kind;
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the path.
/// </summary>
/// <remarks>
/// Required, Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string Path { get; set; }
/// <summary>
/// Gets or sets the path.
/// </summary>
/// <remarks>
/// Required, Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string Path { get; set; }
/// <summary>
/// Gets or sets the kind of artwork.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public ArtKind Kind { get; set; }
/// <summary>
/// Gets or sets the kind of artwork.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public ArtKind Kind { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -2,31 +2,35 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1128 // Put constructor initializers on their own line
#pragma warning disable CA1724
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a book.
/// </summary>
public class Book : LibraryItem, IHasReleases
{
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Book"/> class.
/// An entity representing a book.
/// </summary>
/// <param name="library">The library.</param>
public Book(Library library) : base(library)
public class Book : LibraryItem, IHasReleases
{
BookMetadata = new HashSet<BookMetadata>();
Releases = new HashSet<Release>();
/// <summary>
/// Initializes a new instance of the <see cref="Book"/> class.
/// </summary>
/// <param name="library">The library.</param>
public Book(Library library) : base(library)
{
this.BookMetadata = new HashSet<BookMetadata>();
this.Releases = new HashSet<Release>();
}
/// <summary>
/// Gets a collection containing the metadata for this book.
/// </summary>
public virtual ICollection<BookMetadata> BookMetadata { get; private set; }
/// <inheritdoc />
public virtual ICollection<Release> Releases { get; private set; }
}
/// <summary>
/// Gets a collection containing the metadata for this book.
/// </summary>
public virtual ICollection<BookMetadata> BookMetadata { get; private set; }
/// <inheritdoc />
public virtual ICollection<Release> Releases { get; private set; }
}
@@ -2,36 +2,39 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1128 // Put constructor initializers on their own line
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity containing metadata for a book.
/// </summary>
public class BookMetadata : ItemMetadata, IHasCompanies
{
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="BookMetadata"/> class.
/// An entity containing metadata for a book.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public BookMetadata(string title, string language) : base(title, language)
public class BookMetadata : ItemMetadata, IHasCompanies
{
Publishers = new HashSet<Company>();
/// <summary>
/// Initializes a new instance of the <see cref="BookMetadata"/> class.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public BookMetadata(string title, string language) : base(title, language)
{
this.Publishers = new HashSet<Company>();
}
/// <summary>
/// Gets or sets the ISBN.
/// </summary>
public long? Isbn { get; set; }
/// <summary>
/// Gets a collection of the publishers for this book.
/// </summary>
public virtual ICollection<Company> Publishers { get; private set; }
/// <inheritdoc />
public ICollection<Company> Companies => this.Publishers;
}
/// <summary>
/// Gets or sets the ISBN.
/// </summary>
public long? Isbn { get; set; }
/// <summary>
/// Gets a collection of the publishers for this book.
/// </summary>
public virtual ICollection<Company> Publishers { get; private set; }
/// <inheritdoc />
public ICollection<Company> Companies => Publishers;
}
@@ -3,81 +3,82 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a chapter.
/// </summary>
public class Chapter : IHasConcurrencyToken
{
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Chapter"/> class.
/// An entity representing a chapter.
/// </summary>
/// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="startTime">The start time for this chapter.</param>
public Chapter(string language, long startTime)
public class Chapter : IHasConcurrencyToken
{
ArgumentException.ThrowIfNullOrEmpty(language);
/// <summary>
/// Initializes a new instance of the <see cref="Chapter"/> class.
/// </summary>
/// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="startTime">The start time for this chapter.</param>
public Chapter(string language, long startTime)
{
ArgumentException.ThrowIfNullOrEmpty(language);
Language = language;
StartTime = startTime;
}
this.Language = language;
this.StartTime = startTime;
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Name { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Name { get; set; }
/// <summary>
/// Gets or sets the language.
/// </summary>
/// <remarks>
/// Required, Min length = 3, Max length = 3
/// ISO-639-3 3-character language codes.
/// </remarks>
[MinLength(3)]
[MaxLength(3)]
[StringLength(3)]
public string Language { get; set; }
/// <summary>
/// Gets or sets the language.
/// </summary>
/// <remarks>
/// Required, Min length = 3, Max length = 3
/// ISO-639-3 3-character language codes.
/// </remarks>
[MinLength(3)]
[MaxLength(3)]
[StringLength(3)]
public string Language { get; set; }
/// <summary>
/// Gets or sets the start time.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public long StartTime { get; set; }
/// <summary>
/// Gets or sets the start time.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public long StartTime { get; set; }
/// <summary>
/// Gets or sets the end time.
/// </summary>
public long? EndTime { get; set; }
/// <summary>
/// Gets or sets the end time.
/// </summary>
public long? EndTime { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -5,56 +5,57 @@
#pragma warning disable CA1711 // Identifiers should not have incorrect suffix
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a collection.
/// </summary>
public class Collection : IHasConcurrencyToken
{
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Collection"/> class.
/// An entity representing a collection.
/// </summary>
public Collection()
public class Collection : IHasConcurrencyToken
{
Items = new HashSet<CollectionItem>();
}
/// <summary>
/// Initializes a new instance of the <see cref="Collection"/> class.
/// </summary>
public Collection()
{
this.Items = new HashSet<CollectionItem>();
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Name { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Name { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets a collection containing this collection's items.
/// </summary>
public virtual ICollection<CollectionItem> Items { get; private set; }
/// <summary>
/// Gets a collection containing this collection's items.
/// </summary>
public virtual ICollection<CollectionItem> Items { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -2,66 +2,69 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable CA1716 // Ignore keyword
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a collection item.
/// </summary>
public class CollectionItem : IHasConcurrencyToken
{
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="CollectionItem"/> class.
/// An entity representing a collection item.
/// </summary>
/// <param name="libraryItem">The library item.</param>
public CollectionItem(LibraryItem libraryItem)
public class CollectionItem : IHasConcurrencyToken
{
LibraryItem = libraryItem;
}
/// <summary>
/// Initializes a new instance of the <see cref="CollectionItem"/> class.
/// </summary>
/// <param name="libraryItem">The library item.</param>
public CollectionItem(LibraryItem libraryItem)
{
this.LibraryItem = libraryItem;
}
/// <summary>
/// Gets or sets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
/// <summary>
/// Gets or sets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets or sets the library item.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public virtual LibraryItem LibraryItem { get; set; }
/// <summary>
/// Gets or sets the library item.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public virtual LibraryItem LibraryItem { get; set; }
/// <summary>
/// Gets or sets the next item in the collection.
/// </summary>
/// <remarks>
/// TODO check if this properly updated Dependent and has the proper principal relationship.
/// </remarks>
public virtual CollectionItem? Next { get; set; }
/// <summary>
/// Gets or sets the next item in the collection.
/// </summary>
/// <remarks>
/// TODO check if this properly updated Dependent and has the proper principal relationship.
/// </remarks>
public virtual CollectionItem? Next { get; set; }
/// <summary>
/// Gets or sets the previous item in the collection.
/// </summary>
/// <remarks>
/// TODO check if this properly updated Dependent and has the proper principal relationship.
/// </remarks>
public virtual CollectionItem? Previous { get; set; }
/// <summary>
/// Gets or sets the previous item in the collection.
/// </summary>
/// <remarks>
/// TODO check if this properly updated Dependent and has the proper principal relationship.
/// </remarks>
public virtual CollectionItem? Previous { get; set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -3,55 +3,56 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a company.
/// </summary>
public class Company : IHasCompanies, IHasConcurrencyToken
{
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Company"/> class.
/// An entity representing a company.
/// </summary>
public Company()
public class Company : IHasCompanies, IHasConcurrencyToken
{
CompanyMetadata = new HashSet<CompanyMetadata>();
ChildCompanies = new HashSet<Company>();
}
/// <summary>
/// Initializes a new instance of the <see cref="Company"/> class.
/// </summary>
public Company()
{
this.CompanyMetadata = new HashSet<CompanyMetadata>();
this.ChildCompanies = new HashSet<Company>();
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets a collection containing the metadata.
/// </summary>
public virtual ICollection<CompanyMetadata> CompanyMetadata { get; private set; }
/// <summary>
/// Gets a collection containing the metadata.
/// </summary>
public virtual ICollection<CompanyMetadata> CompanyMetadata { get; private set; }
/// <summary>
/// Gets a collection containing this company's child companies.
/// </summary>
public virtual ICollection<Company> ChildCompanies { get; private set; }
/// <summary>
/// Gets a collection containing this company's child companies.
/// </summary>
public virtual ICollection<Company> ChildCompanies { get; private set; }
/// <inheritdoc />
public ICollection<Company> Companies => ChildCompanies;
/// <inheritdoc />
public ICollection<Company> Companies => this.ChildCompanies;
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -2,61 +2,64 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1128 // Put constructor initializers on their own line
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.ComponentModel.DataAnnotations;
/// <summary>
/// An entity holding metadata for a <see cref="Company"/>.
/// </summary>
public class CompanyMetadata : ItemMetadata
{
using System.ComponentModel.DataAnnotations;
/// <summary>
/// Initializes a new instance of the <see cref="CompanyMetadata"/> class.
/// An entity holding metadata for a <see cref="Company"/>.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public CompanyMetadata(string title, string language) : base(title, language)
public class CompanyMetadata : ItemMetadata
{
/// <summary>
/// Initializes a new instance of the <see cref="CompanyMetadata"/> class.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public CompanyMetadata(string title, string language) : base(title, language)
{
}
/// <summary>
/// Gets or sets the description.
/// </summary>
/// <remarks>
/// Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string? Description { get; set; }
/// <summary>
/// Gets or sets the headquarters.
/// </summary>
/// <remarks>
/// Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string? Headquarters { get; set; }
/// <summary>
/// Gets or sets the country code.
/// </summary>
/// <remarks>
/// Max length = 2.
/// </remarks>
[MaxLength(2)]
[StringLength(2)]
public string? Country { get; set; }
/// <summary>
/// Gets or sets the homepage.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Homepage { get; set; }
}
/// <summary>
/// Gets or sets the description.
/// </summary>
/// <remarks>
/// Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string? Description { get; set; }
/// <summary>
/// Gets or sets the headquarters.
/// </summary>
/// <remarks>
/// Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string? Headquarters { get; set; }
/// <summary>
/// Gets or sets the country code.
/// </summary>
/// <remarks>
/// Max length = 2.
/// </remarks>
[MaxLength(2)]
[StringLength(2)]
public string? Country { get; set; }
/// <summary>
/// Gets or sets the homepage.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Homepage { get; set; }
}
@@ -2,31 +2,34 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1128 // Put constructor initializers on their own line
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a custom item.
/// </summary>
public class CustomItem : LibraryItem, IHasReleases
{
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="CustomItem"/> class.
/// An entity representing a custom item.
/// </summary>
/// <param name="library">The library.</param>
public CustomItem(Library library) : base(library)
public class CustomItem : LibraryItem, IHasReleases
{
CustomItemMetadata = new HashSet<CustomItemMetadata>();
Releases = new HashSet<Release>();
/// <summary>
/// Initializes a new instance of the <see cref="CustomItem"/> class.
/// </summary>
/// <param name="library">The library.</param>
public CustomItem(Library library) : base(library)
{
this.CustomItemMetadata = new HashSet<CustomItemMetadata>();
this.Releases = new HashSet<Release>();
}
/// <summary>
/// Gets a collection containing the metadata for this item.
/// </summary>
public virtual ICollection<CustomItemMetadata> CustomItemMetadata { get; private set; }
/// <inheritdoc />
public virtual ICollection<Release> Releases { get; private set; }
}
/// <summary>
/// Gets a collection containing the metadata for this item.
/// </summary>
public virtual ICollection<CustomItemMetadata> CustomItemMetadata { get; private set; }
/// <inheritdoc />
public virtual ICollection<Release> Releases { get; private set; }
}
@@ -2,19 +2,22 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
#pragma warning disable SA1128 // Put constructor initializers on their own line
/// <summary>
/// An entity containing metadata for a custom item.
/// </summary>
public class CustomItemMetadata : ItemMetadata
namespace Jellyfin.Database.Implementations.Entities.Libraries
{
/// <summary>
/// Initializes a new instance of the <see cref="CustomItemMetadata"/> class.
/// An entity containing metadata for a custom item.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public CustomItemMetadata(string title, string language) : base(title, language)
public class CustomItemMetadata : ItemMetadata
{
/// <summary>
/// Initializes a new instance of the <see cref="CustomItemMetadata"/> class.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public CustomItemMetadata(string title, string language) : base(title, language)
{
}
}
}
@@ -2,36 +2,39 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1128 // Put constructor initializers on their own line
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing an episode.
/// </summary>
public class Episode : LibraryItem, IHasReleases
{
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Episode"/> class.
/// An entity representing an episode.
/// </summary>
/// <param name="library">The library.</param>
public Episode(Library library) : base(library)
public class Episode : LibraryItem, IHasReleases
{
Releases = new HashSet<Release>();
EpisodeMetadata = new HashSet<EpisodeMetadata>();
/// <summary>
/// Initializes a new instance of the <see cref="Episode"/> class.
/// </summary>
/// <param name="library">The library.</param>
public Episode(Library library) : base(library)
{
this.Releases = new HashSet<Release>();
this.EpisodeMetadata = new HashSet<EpisodeMetadata>();
}
/// <summary>
/// Gets or sets the episode number.
/// </summary>
public int? EpisodeNumber { get; set; }
/// <inheritdoc />
public virtual ICollection<Release> Releases { get; private set; }
/// <summary>
/// Gets a collection containing the metadata for this episode.
/// </summary>
public virtual ICollection<EpisodeMetadata> EpisodeMetadata { get; private set; }
}
/// <summary>
/// Gets or sets the episode number.
/// </summary>
public int? EpisodeNumber { get; set; }
/// <inheritdoc />
public virtual ICollection<Release> Releases { get; private set; }
/// <summary>
/// Gets a collection containing the metadata for this episode.
/// </summary>
public virtual ICollection<EpisodeMetadata> EpisodeMetadata { get; private set; }
}
@@ -2,51 +2,54 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1128 // Put constructor initializers on their own line
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.ComponentModel.DataAnnotations;
/// <summary>
/// An entity containing metadata for an <see cref="Episode"/>.
/// </summary>
public class EpisodeMetadata : ItemMetadata
{
using System.ComponentModel.DataAnnotations;
/// <summary>
/// Initializes a new instance of the <see cref="EpisodeMetadata"/> class.
/// An entity containing metadata for an <see cref="Episode"/>.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public EpisodeMetadata(string title, string language) : base(title, language)
public class EpisodeMetadata : ItemMetadata
{
/// <summary>
/// Initializes a new instance of the <see cref="EpisodeMetadata"/> class.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public EpisodeMetadata(string title, string language) : base(title, language)
{
}
/// <summary>
/// Gets or sets the outline.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Outline { get; set; }
/// <summary>
/// Gets or sets the plot.
/// </summary>
/// <remarks>
/// Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string? Plot { get; set; }
/// <summary>
/// Gets or sets the tagline.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Tagline { get; set; }
}
/// <summary>
/// Gets or sets the outline.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Outline { get; set; }
/// <summary>
/// Gets or sets the plot.
/// </summary>
/// <remarks>
/// Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string? Plot { get; set; }
/// <summary>
/// Gets or sets the tagline.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Tagline { get; set; }
}
@@ -3,51 +3,52 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a genre.
/// </summary>
public class Genre : IHasConcurrencyToken
{
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Genre"/> class.
/// An entity representing a genre.
/// </summary>
/// <param name="name">The name.</param>
public Genre(string name)
public class Genre : IHasConcurrencyToken
{
Name = name;
}
/// <summary>
/// Initializes a new instance of the <see cref="Genre"/> class.
/// </summary>
/// <param name="name">The name.</param>
public Genre(string name)
{
this.Name = name;
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Indexed, Required, Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string Name { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Indexed, Required, Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string Name { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -3,142 +3,143 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An abstract class that holds metadata.
/// </summary>
public abstract class ItemMetadata : IHasArtwork, IHasConcurrencyToken
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="ItemMetadata"/> class.
/// An abstract class that holds metadata.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
protected ItemMetadata(string title, string language)
public abstract class ItemMetadata : IHasArtwork, IHasConcurrencyToken
{
ArgumentException.ThrowIfNullOrEmpty(title);
ArgumentException.ThrowIfNullOrEmpty(language);
/// <summary>
/// Initializes a new instance of the <see cref="ItemMetadata"/> class.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
protected ItemMetadata(string title, string language)
{
ArgumentException.ThrowIfNullOrEmpty(title);
ArgumentException.ThrowIfNullOrEmpty(language);
Title = title;
Language = language;
DateAdded = DateTime.UtcNow;
DateModified = DateAdded;
this.Title = title;
this.Language = language;
this.DateAdded = DateTime.UtcNow;
this.DateModified = this.DateAdded;
PersonRoles = new HashSet<PersonRole>();
Genres = new HashSet<Genre>();
Artwork = new HashSet<Artwork>();
Ratings = new HashSet<Rating>();
Sources = new HashSet<MetadataProviderId>();
}
this.PersonRoles = new HashSet<PersonRole>();
this.Genres = new HashSet<Genre>();
this.Artwork = new HashSet<Artwork>();
this.Ratings = new HashSet<Rating>();
this.Sources = new HashSet<MetadataProviderId>();
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <remarks>
/// Required, Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string Title { get; set; }
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <remarks>
/// Required, Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string Title { get; set; }
/// <summary>
/// Gets or sets the original title.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? OriginalTitle { get; set; }
/// <summary>
/// Gets or sets the original title.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? OriginalTitle { get; set; }
/// <summary>
/// Gets or sets the sort title.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? SortTitle { get; set; }
/// <summary>
/// Gets or sets the sort title.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? SortTitle { get; set; }
/// <summary>
/// Gets or sets the language.
/// </summary>
/// <remarks>
/// Required, Min length = 3, Max length = 3.
/// ISO-639-3 3-character language codes.
/// </remarks>
[MinLength(3)]
[MaxLength(3)]
[StringLength(3)]
public string Language { get; set; }
/// <summary>
/// Gets or sets the language.
/// </summary>
/// <remarks>
/// Required, Min length = 3, Max length = 3.
/// ISO-639-3 3-character language codes.
/// </remarks>
[MinLength(3)]
[MaxLength(3)]
[StringLength(3)]
public string Language { get; set; }
/// <summary>
/// Gets or sets the release date.
/// </summary>
public DateTimeOffset? ReleaseDate { get; set; }
/// <summary>
/// Gets or sets the release date.
/// </summary>
public DateTimeOffset? ReleaseDate { get; set; }
/// <summary>
/// Gets the date added.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public DateTime DateAdded { get; private set; }
/// <summary>
/// Gets the date added.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public DateTime DateAdded { get; private set; }
/// <summary>
/// Gets or sets the date modified.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public DateTime DateModified { get; set; }
/// <summary>
/// Gets or sets the date modified.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public DateTime DateModified { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets a collection containing the person roles for this item.
/// </summary>
public virtual ICollection<PersonRole> PersonRoles { get; private set; }
/// <summary>
/// Gets a collection containing the person roles for this item.
/// </summary>
public virtual ICollection<PersonRole> PersonRoles { get; private set; }
/// <summary>
/// Gets a collection containing the genres for this item.
/// </summary>
public virtual ICollection<Genre> Genres { get; private set; }
/// <summary>
/// Gets a collection containing the genres for this item.
/// </summary>
public virtual ICollection<Genre> Genres { get; private set; }
/// <inheritdoc />
public virtual ICollection<Artwork> Artwork { get; private set; }
/// <inheritdoc />
public virtual ICollection<Artwork> Artwork { get; private set; }
/// <summary>
/// Gets a collection containing the ratings for this item.
/// </summary>
public virtual ICollection<Rating> Ratings { get; private set; }
/// <summary>
/// Gets a collection containing the ratings for this item.
/// </summary>
public virtual ICollection<Rating> Ratings { get; private set; }
/// <summary>
/// Gets a collection containing the metadata sources for this item.
/// </summary>
public virtual ICollection<MetadataProviderId> Sources { get; private set; }
/// <summary>
/// Gets a collection containing the metadata sources for this item.
/// </summary>
public virtual ICollection<MetadataProviderId> Sources { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -2,62 +2,65 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable CA1724
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a library.
/// </summary>
public class Library : IHasConcurrencyToken
{
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Library"/> class.
/// An entity representing a library.
/// </summary>
/// <param name="name">The name of the library.</param>
/// <param name="path">The path of the library.</param>
public Library(string name, string path)
public class Library : IHasConcurrencyToken
{
Name = name;
Path = path;
/// <summary>
/// Initializes a new instance of the <see cref="Library"/> class.
/// </summary>
/// <param name="name">The name of the library.</param>
/// <param name="path">The path of the library.</param>
public Library(string name, string path)
{
this.Name = name;
this.Path = path;
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Required, Max length = 128.
/// </remarks>
[MaxLength(128)]
[StringLength(128)]
public string Name { get; set; }
/// <summary>
/// Gets or sets the root path of the library.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public string Path { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Required, Max length = 128.
/// </remarks>
[MaxLength(128)]
[StringLength(128)]
public string Name { get; set; }
/// <summary>
/// Gets or sets the root path of the library.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public string Path { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
}
}
}
@@ -3,56 +3,57 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a library item.
/// </summary>
public abstract class LibraryItem : IHasConcurrencyToken
{
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="LibraryItem"/> class.
/// An entity representing a library item.
/// </summary>
/// <param name="library">The library of this item.</param>
protected LibraryItem(Library library)
public abstract class LibraryItem : IHasConcurrencyToken
{
DateAdded = DateTime.UtcNow;
Library = library;
}
/// <summary>
/// Initializes a new instance of the <see cref="LibraryItem"/> class.
/// </summary>
/// <param name="library">The library of this item.</param>
protected LibraryItem(Library library)
{
this.DateAdded = DateTime.UtcNow;
this.Library = library;
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the date this library item was added.
/// </summary>
public DateTime DateAdded { get; private set; }
/// <summary>
/// Gets the date this library item was added.
/// </summary>
public DateTime DateAdded { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets or sets the library of this item.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public virtual Library Library { get; set; }
/// <summary>
/// Gets or sets the library of this item.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public virtual Library Library { get; set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -3,73 +3,74 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a file on disk.
/// </summary>
public class MediaFile : IHasConcurrencyToken
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="MediaFile"/> class.
/// An entity representing a file on disk.
/// </summary>
/// <param name="path">The path relative to the LibraryRoot.</param>
/// <param name="kind">The file kind.</param>
public MediaFile(string path, MediaFileKind kind)
public class MediaFile : IHasConcurrencyToken
{
ArgumentException.ThrowIfNullOrEmpty(path);
/// <summary>
/// Initializes a new instance of the <see cref="MediaFile"/> class.
/// </summary>
/// <param name="path">The path relative to the LibraryRoot.</param>
/// <param name="kind">The file kind.</param>
public MediaFile(string path, MediaFileKind kind)
{
ArgumentException.ThrowIfNullOrEmpty(path);
Path = path;
Kind = kind;
this.Path = path;
this.Kind = kind;
MediaFileStreams = new HashSet<MediaFileStream>();
}
this.MediaFileStreams = new HashSet<MediaFileStream>();
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the path relative to the library root.
/// </summary>
/// <remarks>
/// Required, Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string Path { get; set; }
/// <summary>
/// Gets or sets the path relative to the library root.
/// </summary>
/// <remarks>
/// Required, Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string Path { get; set; }
/// <summary>
/// Gets or sets the kind of media file.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public MediaFileKind Kind { get; set; }
/// <summary>
/// Gets or sets the kind of media file.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public MediaFileKind Kind { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets a collection containing the streams in this file.
/// </summary>
public virtual ICollection<MediaFileStream> MediaFileStreams { get; private set; }
/// <summary>
/// Gets a collection containing the streams in this file.
/// </summary>
public virtual ICollection<MediaFileStream> MediaFileStreams { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -3,51 +3,52 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
{
#pragma warning disable CA1711 // Identifiers should not have incorrect suffix
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a stream in a media file.
/// </summary>
public class MediaFileStream : IHasConcurrencyToken
{
/// <summary>
/// Initializes a new instance of the <see cref="MediaFileStream"/> class.
/// An entity representing a stream in a media file.
/// </summary>
/// <param name="streamNumber">The number of this stream.</param>
public MediaFileStream(int streamNumber)
public class MediaFileStream : IHasConcurrencyToken
{
StreamNumber = streamNumber;
}
/// <summary>
/// Initializes a new instance of the <see cref="MediaFileStream"/> class.
/// </summary>
/// <param name="streamNumber">The number of this stream.</param>
public MediaFileStream(int streamNumber)
{
this.StreamNumber = streamNumber;
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the stream number.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int StreamNumber { get; set; }
/// <summary>
/// Gets or sets the stream number.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int StreamNumber { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -3,54 +3,55 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a metadata provider.
/// </summary>
public class MetadataProvider : IHasConcurrencyToken
{
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="MetadataProvider"/> class.
/// An entity representing a metadata provider.
/// </summary>
/// <param name="name">The name of the metadata provider.</param>
public MetadataProvider(string name)
public class MetadataProvider : IHasConcurrencyToken
{
ArgumentException.ThrowIfNullOrEmpty(name);
/// <summary>
/// Initializes a new instance of the <see cref="MetadataProvider"/> class.
/// </summary>
/// <param name="name">The name of the metadata provider.</param>
public MetadataProvider(string name)
{
ArgumentException.ThrowIfNullOrEmpty(name);
Name = name;
}
this.Name = name;
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Required, Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string Name { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Required, Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string Name { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -3,65 +3,65 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a unique identifier for a metadata provider.
/// </summary>
public class MetadataProviderId : IHasConcurrencyToken
{
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="MetadataProviderId"/> class.
/// An entity representing a unique identifier for a metadata provider.
/// </summary>
/// <param name="providerId">The provider id.</param>
/// <param name="metadataProvider">The metadata provider.</param>
public MetadataProviderId(string providerId, MetadataProvider metadataProvider)
public class MetadataProviderId : IHasConcurrencyToken
{
ArgumentException.ThrowIfNullOrEmpty(providerId);
/// <summary>
/// Initializes a new instance of the <see cref="MetadataProviderId"/> class.
/// </summary>
/// <param name="providerId">The provider id.</param>
/// <param name="metadataProvider">The metadata provider.</param>
public MetadataProviderId(string providerId, MetadataProvider metadataProvider)
{
ArgumentException.ThrowIfNullOrEmpty(providerId);
ProviderId = providerId;
MetadataProvider = metadataProvider;
}
this.ProviderId = providerId;
this.MetadataProvider = metadataProvider;
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the provider id.
/// </summary>
/// <remarks>
/// Required, Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string ProviderId { get; set; }
/// <summary>
/// Gets or sets the provider id.
/// </summary>
/// <remarks>
/// Required, Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string ProviderId { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets or sets the metadata provider.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public virtual MetadataProvider MetadataProvider { get; set; }
/// <summary>
/// Gets or sets the metadata provider.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public virtual MetadataProvider MetadataProvider { get; set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -2,31 +2,35 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1128 // Put constructor initializers on their own line
#pragma warning disable CA1724
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a movie.
/// </summary>
public class Movie : LibraryItem, IHasReleases
{
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Movie"/> class.
/// An entity representing a movie.
/// </summary>
/// <param name="library">The library.</param>
public Movie(Library library) : base(library)
public class Movie : LibraryItem, IHasReleases
{
Releases = new HashSet<Release>();
MovieMetadata = new HashSet<MovieMetadata>();
/// <summary>
/// Initializes a new instance of the <see cref="Movie"/> class.
/// </summary>
/// <param name="library">The library.</param>
public Movie(Library library) : base(library)
{
this.Releases = new HashSet<Release>();
this.MovieMetadata = new HashSet<MovieMetadata>();
}
/// <inheritdoc />
public virtual ICollection<Release> Releases { get; private set; }
/// <summary>
/// Gets a collection containing the metadata for this movie.
/// </summary>
public virtual ICollection<MovieMetadata> MovieMetadata { get; private set; }
}
/// <inheritdoc />
public virtual ICollection<Release> Releases { get; private set; }
/// <summary>
/// Gets a collection containing the metadata for this movie.
/// </summary>
public virtual ICollection<MovieMetadata> MovieMetadata { get; private set; }
}
@@ -2,72 +2,75 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1128 // Put constructor initializers on their own line
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity holding the metadata for a movie.
/// </summary>
public class MovieMetadata : ItemMetadata, IHasCompanies
{
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="MovieMetadata"/> class.
/// An entity holding the metadata for a movie.
/// </summary>
/// <param name="title">The title or name of the movie.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public MovieMetadata(string title, string language) : base(title, language)
public class MovieMetadata : ItemMetadata, IHasCompanies
{
Studios = new HashSet<Company>();
/// <summary>
/// Initializes a new instance of the <see cref="MovieMetadata"/> class.
/// </summary>
/// <param name="title">The title or name of the movie.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public MovieMetadata(string title, string language) : base(title, language)
{
this.Studios = new HashSet<Company>();
}
/// <summary>
/// Gets or sets the outline.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Outline { get; set; }
/// <summary>
/// Gets or sets the tagline.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Tagline { get; set; }
/// <summary>
/// Gets or sets the plot.
/// </summary>
/// <remarks>
/// Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string? Plot { get; set; }
/// <summary>
/// Gets or sets the country code.
/// </summary>
/// <remarks>
/// Max length = 2.
/// </remarks>
[MaxLength(2)]
[StringLength(2)]
public string? Country { get; set; }
/// <summary>
/// Gets the studios that produced this movie.
/// </summary>
public virtual ICollection<Company> Studios { get; private set; }
/// <inheritdoc />
public ICollection<Company> Companies => this.Studios;
}
/// <summary>
/// Gets or sets the outline.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Outline { get; set; }
/// <summary>
/// Gets or sets the tagline.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Tagline { get; set; }
/// <summary>
/// Gets or sets the plot.
/// </summary>
/// <remarks>
/// Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string? Plot { get; set; }
/// <summary>
/// Gets or sets the country code.
/// </summary>
/// <remarks>
/// Max length = 2.
/// </remarks>
[MaxLength(2)]
[StringLength(2)]
public string? Country { get; set; }
/// <summary>
/// Gets the studios that produced this movie.
/// </summary>
public virtual ICollection<Company> Studios { get; private set; }
/// <inheritdoc />
public ICollection<Company> Companies => Studios;
}
@@ -2,32 +2,36 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1128 // Put constructor initializers on their own line
#pragma warning disable CA1724
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.Collections.Generic;
/// <summary>
/// An entity representing a music album.
/// </summary>
public class MusicAlbum : LibraryItem
{
using System.Collections.Generic;
/// <summary>
/// Initializes a new instance of the <see cref="MusicAlbum"/> class.
/// An entity representing a music album.
/// </summary>
/// <param name="library">The library.</param>
public MusicAlbum(Library library) : base(library)
public class MusicAlbum : LibraryItem
{
MusicAlbumMetadata = new HashSet<MusicAlbumMetadata>();
Tracks = new HashSet<Track>();
/// <summary>
/// Initializes a new instance of the <see cref="MusicAlbum"/> class.
/// </summary>
/// <param name="library">The library.</param>
public MusicAlbum(Library library) : base(library)
{
this.MusicAlbumMetadata = new HashSet<MusicAlbumMetadata>();
this.Tracks = new HashSet<Track>();
}
/// <summary>
/// Gets a collection containing the album metadata.
/// </summary>
public virtual ICollection<MusicAlbumMetadata> MusicAlbumMetadata { get; private set; }
/// <summary>
/// Gets a collection containing the tracks.
/// </summary>
public virtual ICollection<Track> Tracks { get; private set; }
}
/// <summary>
/// Gets a collection containing the album metadata.
/// </summary>
public virtual ICollection<MusicAlbumMetadata> MusicAlbumMetadata { get; private set; }
/// <summary>
/// Gets a collection containing the tracks.
/// </summary>
public virtual ICollection<Track> Tracks { get; private set; }
}
@@ -2,58 +2,62 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable CA1724
#pragma warning disable SA1128 // Put constructor initializers on their own line
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
/// <summary>
/// An entity holding the metadata for a music album.
/// </summary>
public class MusicAlbumMetadata : ItemMetadata
{
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
/// <summary>
/// Initializes a new instance of the <see cref="MusicAlbumMetadata"/> class.
/// An entity holding the metadata for a music album.
/// </summary>
/// <param name="title">The title or name of the album.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public MusicAlbumMetadata(string title, string language) : base(title, language)
public class MusicAlbumMetadata : ItemMetadata
{
Labels = new HashSet<Company>();
/// <summary>
/// Initializes a new instance of the <see cref="MusicAlbumMetadata"/> class.
/// </summary>
/// <param name="title">The title or name of the album.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public MusicAlbumMetadata(string title, string language) : base(title, language)
{
this.Labels = new HashSet<Company>();
}
/// <summary>
/// Gets or sets the barcode.
/// </summary>
/// <remarks>
/// Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string? Barcode { get; set; }
/// <summary>
/// Gets or sets the label number.
/// </summary>
/// <remarks>
/// Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string? LabelNumber { get; set; }
/// <summary>
/// Gets or sets the country code.
/// </summary>
/// <remarks>
/// Max length = 2.
/// </remarks>
[MaxLength(2)]
[StringLength(2)]
public string? Country { get; set; }
/// <summary>
/// Gets a collection containing the labels.
/// </summary>
public virtual ICollection<Company> Labels { get; private set; }
}
/// <summary>
/// Gets or sets the barcode.
/// </summary>
/// <remarks>
/// Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string? Barcode { get; set; }
/// <summary>
/// Gets or sets the label number.
/// </summary>
/// <remarks>
/// Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string? LabelNumber { get; set; }
/// <summary>
/// Gets or sets the country code.
/// </summary>
/// <remarks>
/// Max length = 2.
/// </remarks>
[MaxLength(2)]
[StringLength(2)]
public string? Country { get; set; }
/// <summary>
/// Gets a collection containing the labels.
/// </summary>
public virtual ICollection<Company> Labels { get; private set; }
}
@@ -2,91 +2,94 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable CA1724
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a person.
/// </summary>
public class Person : IHasConcurrencyToken
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Person"/> class.
/// An entity representing a person.
/// </summary>
/// <param name="name">The name of the person.</param>
public Person(string name)
public class Person : IHasConcurrencyToken
{
ArgumentException.ThrowIfNullOrEmpty(name);
/// <summary>
/// Initializes a new instance of the <see cref="Person"/> class.
/// </summary>
/// <param name="name">The name of the person.</param>
public Person(string name)
{
ArgumentException.ThrowIfNullOrEmpty(name);
Name = name;
DateAdded = DateTime.UtcNow;
DateModified = DateAdded;
this.Name = name;
this.DateAdded = DateTime.UtcNow;
this.DateModified = this.DateAdded;
Sources = new HashSet<MetadataProviderId>();
}
this.Sources = new HashSet<MetadataProviderId>();
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Required, Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string Name { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Required, Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string Name { get; set; }
/// <summary>
/// Gets or sets the source id.
/// </summary>
/// <remarks>
/// Max length = 255.
/// </remarks>
[MaxLength(256)]
[StringLength(256)]
public string? SourceId { get; set; }
/// <summary>
/// Gets or sets the source id.
/// </summary>
/// <remarks>
/// Max length = 255.
/// </remarks>
[MaxLength(256)]
[StringLength(256)]
public string? SourceId { get; set; }
/// <summary>
/// Gets the date added.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public DateTime DateAdded { get; private set; }
/// <summary>
/// Gets the date added.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public DateTime DateAdded { get; private set; }
/// <summary>
/// Gets or sets the date modified.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public DateTime DateModified { get; set; }
/// <summary>
/// Gets or sets the date modified.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public DateTime DateModified { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets a list of metadata sources for this person.
/// </summary>
public virtual ICollection<MetadataProviderId> Sources { get; private set; }
/// <summary>
/// Gets a list of metadata sources for this person.
/// </summary>
public virtual ICollection<MetadataProviderId> Sources { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -3,81 +3,82 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a person's role in media.
/// </summary>
public class PersonRole : IHasArtwork, IHasConcurrencyToken
{
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="PersonRole"/> class.
/// An entity representing a person's role in media.
/// </summary>
/// <param name="type">The role type.</param>
/// <param name="person">The person.</param>
public PersonRole(PersonRoleType type, Person person)
public class PersonRole : IHasArtwork, IHasConcurrencyToken
{
Type = type;
Person = person;
Artwork = new HashSet<Artwork>();
Sources = new HashSet<MetadataProviderId>();
/// <summary>
/// Initializes a new instance of the <see cref="PersonRole"/> class.
/// </summary>
/// <param name="type">The role type.</param>
/// <param name="person">The person.</param>
public PersonRole(PersonRoleType type, Person person)
{
this.Type = type;
this.Person = person;
this.Artwork = new HashSet<Artwork>();
this.Sources = new HashSet<MetadataProviderId>();
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the name of the person's role.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Role { get; set; }
/// <summary>
/// Gets or sets the person's role type.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public PersonRoleType Type { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets or sets the person.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public virtual Person Person { get; set; }
/// <inheritdoc />
public virtual ICollection<Artwork> Artwork { get; private set; }
/// <summary>
/// Gets a collection containing the metadata sources for this person role.
/// </summary>
public virtual ICollection<MetadataProviderId> Sources { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the name of the person's role.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Role { get; set; }
/// <summary>
/// Gets or sets the person's role type.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public PersonRoleType Type { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets or sets the person.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public virtual Person Person { get; set; }
/// <inheritdoc />
public virtual ICollection<Artwork> Artwork { get; private set; }
/// <summary>
/// Gets a collection containing the metadata sources for this person role.
/// </summary>
public virtual ICollection<MetadataProviderId> Sources { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
}
}
}
@@ -2,32 +2,34 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1128 // Put constructor initializers on their own line
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a photo.
/// </summary>
public class Photo : LibraryItem, IHasReleases
{
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Photo"/> class.
/// An entity representing a photo.
/// </summary>
/// <param name="library">The library.</param>
public Photo(Library library) : base(library)
public class Photo : LibraryItem, IHasReleases
{
PhotoMetadata = new HashSet<PhotoMetadata>();
Releases = new HashSet<Release>();
/// <summary>
/// Initializes a new instance of the <see cref="Photo"/> class.
/// </summary>
/// <param name="library">The library.</param>
public Photo(Library library) : base(library)
{
this.PhotoMetadata = new HashSet<PhotoMetadata>();
this.Releases = new HashSet<Release>();
}
/// <summary>
/// Gets a collection containing the photo metadata.
/// </summary>
public virtual ICollection<PhotoMetadata> PhotoMetadata { get; private set; }
/// <inheritdoc />
public virtual ICollection<Release> Releases { get; private set; }
}
/// <summary>
/// Gets a collection containing the photo metadata.
/// </summary>
public virtual ICollection<PhotoMetadata> PhotoMetadata { get; private set; }
/// <inheritdoc />
public virtual ICollection<Release> Releases { get; private set; }
}
@@ -2,20 +2,22 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
#pragma warning disable SA1128 // Put constructor initializers on their own line
/// <summary>
/// An entity that holds metadata for a photo.
/// </summary>
public class PhotoMetadata : ItemMetadata
namespace Jellyfin.Database.Implementations.Entities.Libraries
{
/// <summary>
/// Initializes a new instance of the <see cref="PhotoMetadata"/> class.
/// An entity that holds metadata for a photo.
/// </summary>
/// <param name="title">The title or name of the photo.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public PhotoMetadata(string title, string language) : base(title, language)
public class PhotoMetadata : ItemMetadata
{
/// <summary>
/// Initializes a new instance of the <see cref="PhotoMetadata"/> class.
/// </summary>
/// <param name="title">The title or name of the photo.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public PhotoMetadata(string title, string language) : base(title, language)
{
}
}
}
@@ -2,61 +2,64 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable CA1724
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a rating for an entity.
/// </summary>
public class Rating : IHasConcurrencyToken
{
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Rating"/> class.
/// An entity representing a rating for an entity.
/// </summary>
/// <param name="value">The value.</param>
public Rating(double value)
public class Rating : IHasConcurrencyToken
{
Value = value;
}
/// <summary>
/// Initializes a new instance of the <see cref="Rating"/> class.
/// </summary>
/// <param name="value">The value.</param>
public Rating(double value)
{
this.Value = value;
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the value.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public double Value { get; set; }
/// <summary>
/// Gets or sets the value.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public double Value { get; set; }
/// <summary>
/// Gets or sets the number of votes.
/// </summary>
public int? Votes { get; set; }
/// <summary>
/// Gets or sets the number of votes.
/// </summary>
public int? Votes { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets or sets the rating type.
/// If this is <c>null</c> it's the internal user rating.
/// </summary>
public virtual RatingSource? RatingType { get; set; }
/// <summary>
/// Gets or sets the rating type.
/// If this is <c>null</c> it's the internal user rating.
/// </summary>
public virtual RatingSource? RatingType { get; set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -3,74 +3,75 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// This is the entity to store review ratings, not age ratings.
/// </summary>
public class RatingSource : IHasConcurrencyToken
{
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="RatingSource"/> class.
/// This is the entity to store review ratings, not age ratings.
/// </summary>
/// <param name="minimumValue">The minimum value.</param>
/// <param name="maximumValue">The maximum value.</param>
public RatingSource(double minimumValue, double maximumValue)
public class RatingSource : IHasConcurrencyToken
{
MinimumValue = minimumValue;
MaximumValue = maximumValue;
}
/// <summary>
/// Initializes a new instance of the <see cref="RatingSource"/> class.
/// </summary>
/// <param name="minimumValue">The minimum value.</param>
/// <param name="maximumValue">The maximum value.</param>
public RatingSource(double minimumValue, double maximumValue)
{
this.MinimumValue = minimumValue;
this.MaximumValue = maximumValue;
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Name { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Name { get; set; }
/// <summary>
/// Gets or sets the minimum value.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public double MinimumValue { get; set; }
/// <summary>
/// Gets or sets the minimum value.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public double MinimumValue { get; set; }
/// <summary>
/// Gets or sets the maximum value.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public double MaximumValue { get; set; }
/// <summary>
/// Gets or sets the maximum value.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public double MaximumValue { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets or sets the metadata source.
/// </summary>
public virtual MetadataProviderId? Source { get; set; }
/// <summary>
/// Gets or sets the metadata source.
/// </summary>
public virtual MetadataProviderId? Source { get; set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -3,69 +3,69 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a release for a library item, eg. Director's cut vs. standard.
/// </summary>
public class Release : IHasConcurrencyToken
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Release"/> class.
/// An entity representing a release for a library item, eg. Director's cut vs. standard.
/// </summary>
/// <param name="name">The name of this release.</param>
public Release(string name)
public class Release : IHasConcurrencyToken
{
ArgumentException.ThrowIfNullOrEmpty(name);
/// <summary>
/// Initializes a new instance of the <see cref="Release"/> class.
/// </summary>
/// <param name="name">The name of this release.</param>
public Release(string name)
{
ArgumentException.ThrowIfNullOrEmpty(name);
Name = name;
this.Name = name;
MediaFiles = new HashSet<MediaFile>();
Chapters = new HashSet<Chapter>();
}
this.MediaFiles = new HashSet<MediaFile>();
this.Chapters = new HashSet<Chapter>();
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Required, Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string Name { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <remarks>
/// Required, Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string Name { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets a collection containing the media files for this release.
/// </summary>
public virtual ICollection<MediaFile> MediaFiles { get; private set; }
/// <summary>
/// Gets a collection containing the media files for this release.
/// </summary>
public virtual ICollection<MediaFile> MediaFiles { get; private set; }
/// <summary>
/// Gets a collection containing the chapters for this release.
/// </summary>
public virtual ICollection<Chapter> Chapters { get; private set; }
/// <summary>
/// Gets a collection containing the chapters for this release.
/// </summary>
public virtual ICollection<Chapter> Chapters { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc />
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -2,38 +2,40 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1128 // Put constructor initializers on their own line
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.Collections.Generic;
/// <summary>
/// An entity representing a season.
/// </summary>
public class Season : LibraryItem
{
using System.Collections.Generic;
/// <summary>
/// Initializes a new instance of the <see cref="Season"/> class.
/// An entity representing a season.
/// </summary>
/// <param name="library">The library.</param>
public Season(Library library) : base(library)
public class Season : LibraryItem
{
Episodes = new HashSet<Episode>();
SeasonMetadata = new HashSet<SeasonMetadata>();
/// <summary>
/// Initializes a new instance of the <see cref="Season"/> class.
/// </summary>
/// <param name="library">The library.</param>
public Season(Library library) : base(library)
{
this.Episodes = new HashSet<Episode>();
this.SeasonMetadata = new HashSet<SeasonMetadata>();
}
/// <summary>
/// Gets or sets the season number.
/// </summary>
public int? SeasonNumber { get; set; }
/// <summary>
/// Gets the season metadata.
/// </summary>
public virtual ICollection<SeasonMetadata> SeasonMetadata { get; private set; }
/// <summary>
/// Gets a collection containing the number of episodes.
/// </summary>
public virtual ICollection<Episode> Episodes { get; private set; }
}
/// <summary>
/// Gets or sets the season number.
/// </summary>
public int? SeasonNumber { get; set; }
/// <summary>
/// Gets the season metadata.
/// </summary>
public virtual ICollection<SeasonMetadata> SeasonMetadata { get; private set; }
/// <summary>
/// Gets a collection containing the number of episodes.
/// </summary>
public virtual ICollection<Episode> Episodes { get; private set; }
}
@@ -2,31 +2,34 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1128 // Put constructor initializers on their own line
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.ComponentModel.DataAnnotations;
/// <summary>
/// An entity that holds metadata for seasons.
/// </summary>
public class SeasonMetadata : ItemMetadata
{
/// <summary>
/// Initializes a new instance of the <see cref="SeasonMetadata"/> class.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public SeasonMetadata(string title, string language) : base(title, language)
{
}
using System.ComponentModel.DataAnnotations;
/// <summary>
/// Gets or sets the outline.
/// An entity that holds metadata for seasons.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Outline { get; set; }
public class SeasonMetadata : ItemMetadata
{
/// <summary>
/// Initializes a new instance of the <see cref="SeasonMetadata"/> class.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public SeasonMetadata(string title, string language) : base(title, language)
{
}
/// <summary>
/// Gets or sets the outline.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Outline { get; set; }
}
}
@@ -2,50 +2,52 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1128 // Put constructor initializers on their own line
#pragma warning disable CA1724
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System;
using System.Collections.Generic;
/// <summary>
/// An entity representing a series.
/// </summary>
public class Series : LibraryItem
{
using System;
using System.Collections.Generic;
/// <summary>
/// Initializes a new instance of the <see cref="Series"/> class.
/// An entity representing a series.
/// </summary>
/// <param name="library">The library.</param>
public Series(Library library) : base(library)
public class Series : LibraryItem
{
Seasons = new HashSet<Season>();
SeriesMetadata = new HashSet<SeriesMetadata>();
/// <summary>
/// Initializes a new instance of the <see cref="Series"/> class.
/// </summary>
/// <param name="library">The library.</param>
public Series(Library library) : base(library)
{
this.Seasons = new HashSet<Season>();
this.SeriesMetadata = new HashSet<SeriesMetadata>();
}
/// <summary>
/// Gets or sets the days of week.
/// </summary>
public DayOfWeek? AirsDayOfWeek { get; set; }
/// <summary>
/// Gets or sets the time the show airs, ignore the date portion.
/// </summary>
public DateTimeOffset? AirsTime { get; set; }
/// <summary>
/// Gets or sets the date the series first aired.
/// </summary>
public DateTime? FirstAired { get; set; }
/// <summary>
/// Gets a collection containing the series metadata.
/// </summary>
public virtual ICollection<SeriesMetadata> SeriesMetadata { get; private set; }
/// <summary>
/// Gets a collection containing the seasons.
/// </summary>
public virtual ICollection<Season> Seasons { get; private set; }
}
/// <summary>
/// Gets or sets the days of week.
/// </summary>
public DayOfWeek? AirsDayOfWeek { get; set; }
/// <summary>
/// Gets or sets the time the show airs, ignore the date portion.
/// </summary>
public DateTimeOffset? AirsTime { get; set; }
/// <summary>
/// Gets or sets the date the series first aired.
/// </summary>
public DateTime? FirstAired { get; set; }
/// <summary>
/// Gets a collection containing the series metadata.
/// </summary>
public virtual ICollection<SeriesMetadata> SeriesMetadata { get; private set; }
/// <summary>
/// Gets a collection containing the seasons.
/// </summary>
public virtual ICollection<Season> Seasons { get; private set; }
}
@@ -2,72 +2,75 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1128 // Put constructor initializers on their own line
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing series metadata.
/// </summary>
public class SeriesMetadata : ItemMetadata, IHasCompanies
{
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="SeriesMetadata"/> class.
/// An entity representing series metadata.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public SeriesMetadata(string title, string language) : base(title, language)
public class SeriesMetadata : ItemMetadata, IHasCompanies
{
Networks = new HashSet<Company>();
/// <summary>
/// Initializes a new instance of the <see cref="SeriesMetadata"/> class.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public SeriesMetadata(string title, string language) : base(title, language)
{
this.Networks = new HashSet<Company>();
}
/// <summary>
/// Gets or sets the outline.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Outline { get; set; }
/// <summary>
/// Gets or sets the plot.
/// </summary>
/// <remarks>
/// Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string? Plot { get; set; }
/// <summary>
/// Gets or sets the tagline.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Tagline { get; set; }
/// <summary>
/// Gets or sets the country code.
/// </summary>
/// <remarks>
/// Max length = 2.
/// </remarks>
[MaxLength(2)]
[StringLength(2)]
public string? Country { get; set; }
/// <summary>
/// Gets a collection containing the networks.
/// </summary>
public virtual ICollection<Company> Networks { get; private set; }
/// <inheritdoc />
public ICollection<Company> Companies => this.Networks;
}
/// <summary>
/// Gets or sets the outline.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Outline { get; set; }
/// <summary>
/// Gets or sets the plot.
/// </summary>
/// <remarks>
/// Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string? Plot { get; set; }
/// <summary>
/// Gets or sets the tagline.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? Tagline { get; set; }
/// <summary>
/// Gets or sets the country code.
/// </summary>
/// <remarks>
/// Max length = 2.
/// </remarks>
[MaxLength(2)]
[StringLength(2)]
public string? Country { get; set; }
/// <summary>
/// Gets a collection containing the networks.
/// </summary>
public virtual ICollection<Company> Networks { get; private set; }
/// <inheritdoc />
public ICollection<Company> Companies => Networks;
}
@@ -2,37 +2,39 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1128 // Put constructor initializers on their own line
namespace Jellyfin.Database.Implementations.Entities.Libraries
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a track.
/// </summary>
public class Track : LibraryItem, IHasReleases
{
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Track"/> class.
/// An entity representing a track.
/// </summary>
/// <param name="library">The library.</param>
public Track(Library library) : base(library)
public class Track : LibraryItem, IHasReleases
{
Releases = new HashSet<Release>();
TrackMetadata = new HashSet<TrackMetadata>();
/// <summary>
/// Initializes a new instance of the <see cref="Track"/> class.
/// </summary>
/// <param name="library">The library.</param>
public Track(Library library) : base(library)
{
this.Releases = new HashSet<Release>();
this.TrackMetadata = new HashSet<TrackMetadata>();
}
/// <summary>
/// Gets or sets the track number.
/// </summary>
public int? TrackNumber { get; set; }
/// <inheritdoc />
public virtual ICollection<Release> Releases { get; private set; }
/// <summary>
/// Gets a collection containing the track metadata.
/// </summary>
public virtual ICollection<TrackMetadata> TrackMetadata { get; private set; }
}
/// <summary>
/// Gets or sets the track number.
/// </summary>
public int? TrackNumber { get; set; }
/// <inheritdoc />
public virtual ICollection<Release> Releases { get; private set; }
/// <summary>
/// Gets a collection containing the track metadata.
/// </summary>
public virtual ICollection<TrackMetadata> TrackMetadata { get; private set; }
}
@@ -2,20 +2,22 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Libraries
#pragma warning disable SA1128 // Put constructor initializers on their own line
/// <summary>
/// An entity holding metadata for a track.
/// </summary>
public class TrackMetadata : ItemMetadata
namespace Jellyfin.Database.Implementations.Entities.Libraries
{
/// <summary>
/// Initializes a new instance of the <see cref="TrackMetadata"/> class.
/// An entity holding metadata for a track.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public TrackMetadata(string title, string language) : base(title, language)
public class TrackMetadata : ItemMetadata
{
/// <summary>
/// Initializes a new instance of the <see cref="TrackMetadata"/> class.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
public TrackMetadata(string title, string language) : base(title, language)
{
}
}
}
@@ -5,6 +5,7 @@
namespace Jellyfin.Database.Implementations.Entities;
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable SA1600
using System;
@@ -37,5 +37,5 @@ public enum MediaStreamTypeEntity
/// <summary>
/// The lyric.
/// </summary>
Lyric = 5
Lyric = 5,
}
@@ -3,70 +3,70 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities
{
#pragma warning disable CA1711 // Identifiers should not have incorrect suffix
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Database.Implementations.Interfaces;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing whether the associated user has a specific permission.
/// </summary>
public class Permission : IHasConcurrencyToken
{
/// <summary>
/// Initializes a new instance of the <see cref="Permission"/> class.
/// Public constructor with required data.
/// An entity representing whether the associated user has a specific permission.
/// </summary>
/// <param name="kind">The permission kind.</param>
/// <param name="value">The value of this permission.</param>
public Permission(PermissionKind kind, bool value)
public class Permission : IHasConcurrencyToken
{
Kind = kind;
Value = value;
}
/// <summary>
/// Initializes a new instance of the <see cref="Permission"/> class.
/// Public constructor with required data.
/// </summary>
/// <param name="kind">The permission kind.</param>
/// <param name="value">The value of this permission.</param>
public Permission(PermissionKind kind, bool value)
{
this.Kind = kind;
this.Value = value;
}
/// <summary>
/// Gets the id of this permission.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the id of this permission.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the id of the associated user.
/// </summary>
public Guid? UserId { get; set; }
/// <summary>
/// Gets or sets the id of the associated user.
/// </summary>
public Guid? UserId { get; set; }
/// <summary>
/// Gets the type of this permission.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public PermissionKind Kind { get; private set; }
/// <summary>
/// Gets the type of this permission.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public PermissionKind Kind { get; private set; }
/// <summary>
/// Gets or sets a value indicating whether the associated user has this permission.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool Value { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the associated user has this permission.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool Value { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc/>
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc/>
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -3,69 +3,70 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a preference attached to a user or group.
/// </summary>
public class Preference : IHasConcurrencyToken
{
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="Preference"/> class.
/// Public constructor with required data.
/// An entity representing a preference attached to a user or group.
/// </summary>
/// <param name="kind">The preference kind.</param>
/// <param name="value">The value.</param>
public Preference(PreferenceKind kind, string value)
public class Preference : IHasConcurrencyToken
{
Kind = kind;
Value = value ?? throw new ArgumentNullException(nameof(value));
/// <summary>
/// Initializes a new instance of the <see cref="Preference"/> class.
/// Public constructor with required data.
/// </summary>
/// <param name="kind">The preference kind.</param>
/// <param name="value">The value.</param>
public Preference(PreferenceKind kind, string value)
{
this.Kind = kind;
this.Value = value ?? throw new ArgumentNullException(nameof(value));
}
/// <summary>
/// Gets the id of this preference.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the id of the associated user.
/// </summary>
public Guid? UserId { get; set; }
/// <summary>
/// Gets the type of this preference.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public PreferenceKind Kind { get; private set; }
/// <summary>
/// Gets or sets the value of this preference.
/// </summary>
/// <remarks>
/// Required, Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string Value { get; set; }
/// <inheritdoc/>
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc/>
public void OnSavingChanges()
{
this.RowVersion++;
}
}
/// <summary>
/// Gets the id of this preference.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the id of the associated user.
/// </summary>
public Guid? UserId { get; set; }
/// <summary>
/// Gets the type of this preference.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public PreferenceKind Kind { get; private set; }
/// <summary>
/// Gets or sets the value of this preference.
/// </summary>
/// <remarks>
/// Required, Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string Value { get; set; }
/// <inheritdoc/>
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc/>
public void OnSavingChanges()
{
RowVersion++;
}
}
}
@@ -2,40 +2,41 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace Jellyfin.Database.Implementations.Entities;
/// <summary>
/// Lists types of Audio.
/// </summary>
public enum ProgramAudioEntity
namespace Jellyfin.Database.Implementations.Entities
{
/// <summary>
/// Mono.
/// Lists types of Audio.
/// </summary>
Mono = 0,
public enum ProgramAudioEntity
{
/// <summary>
/// Mono.
/// </summary>
Mono = 0,
/// <summary>
/// Stereo.
/// </summary>
Stereo = 1,
/// <summary>
/// Stereo.
/// </summary>
Stereo = 1,
/// <summary>
/// Dolby.
/// </summary>
Dolby = 2,
/// <summary>
/// Dolby.
/// </summary>
Dolby = 2,
/// <summary>
/// DolbyDigital.
/// </summary>
DolbyDigital = 3,
/// <summary>
/// DolbyDigital.
/// </summary>
DolbyDigital = 3,
/// <summary>
/// Thx.
/// </summary>
Thx = 4,
/// <summary>
/// Thx.
/// </summary>
Thx = 4,
/// <summary>
/// Atmos.
/// </summary>
Atmos = 5
/// <summary>
/// Atmos.
/// </summary>
Atmos = 5,
}
}
@@ -3,57 +3,58 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Security
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Globalization;
/// <summary>
/// An entity representing an API key.
/// </summary>
public class ApiKey
{
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Globalization;
/// <summary>
/// Initializes a new instance of the <see cref="ApiKey"/> class.
/// An entity representing an API key.
/// </summary>
/// <param name="name">The name.</param>
public ApiKey(string name)
public class ApiKey
{
Name = name;
/// <summary>
/// Initializes a new instance of the <see cref="ApiKey"/> class.
/// </summary>
/// <param name="name">The name.</param>
public ApiKey(string name)
{
this.Name = name;
AccessToken = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
DateCreated = DateTime.UtcNow;
this.AccessToken = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
this.DateCreated = DateTime.UtcNow;
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the date created.
/// </summary>
public DateTime DateCreated { get; set; }
/// <summary>
/// Gets or sets the date of last activity.
/// </summary>
public DateTime DateLastActivity { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
[MaxLength(64)]
[StringLength(64)]
public string Name { get; set; }
/// <summary>
/// Gets or sets the access token.
/// </summary>
public string AccessToken { get; set; }
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the date created.
/// </summary>
public DateTime DateCreated { get; set; }
/// <summary>
/// Gets or sets the date of last activity.
/// </summary>
public DateTime DateLastActivity { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
[MaxLength(64)]
[StringLength(64)]
public string Name { get; set; }
/// <summary>
/// Gets or sets the access token.
/// </summary>
public string AccessToken { get; set; }
}
@@ -3,108 +3,109 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Security
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Globalization;
/// <summary>
/// An entity representing a device.
/// </summary>
public class Device
{
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Globalization;
/// <summary>
/// Initializes a new instance of the <see cref="Device"/> class.
/// An entity representing a device.
/// </summary>
/// <param name="userId">The user id.</param>
/// <param name="appName">The app name.</param>
/// <param name="appVersion">The app version.</param>
/// <param name="deviceName">The device name.</param>
/// <param name="deviceId">The device id.</param>
public Device(Guid userId, string appName, string appVersion, string deviceName, string deviceId)
public class Device
{
UserId = userId;
AppName = appName;
AppVersion = appVersion;
DeviceName = deviceName;
DeviceId = deviceId;
/// <summary>
/// Initializes a new instance of the <see cref="Device"/> class.
/// </summary>
/// <param name="userId">The user id.</param>
/// <param name="appName">The app name.</param>
/// <param name="appVersion">The app version.</param>
/// <param name="deviceName">The device name.</param>
/// <param name="deviceId">The device id.</param>
public Device(Guid userId, string appName, string appVersion, string deviceName, string deviceId)
{
this.UserId = userId;
this.AppName = appName;
this.AppVersion = appVersion;
this.DeviceName = deviceName;
this.DeviceId = deviceId;
AccessToken = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
DateCreated = DateTime.UtcNow;
DateModified = DateCreated;
DateLastActivity = DateCreated;
this.AccessToken = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
this.DateCreated = DateTime.UtcNow;
this.DateModified = this.DateCreated;
this.DateLastActivity = this.DateCreated;
// Non-nullable for EF Core, as this is a required relationship.
User = null!;
// Non-nullable for EF Core, as this is a required relationship.
this.User = null!;
}
/// <summary>
/// Gets the id.
/// </summary>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the user id.
/// </summary>
public Guid UserId { get; private set; }
/// <summary>
/// Gets or sets the access token.
/// </summary>
public string AccessToken { get; set; }
/// <summary>
/// Gets or sets the app name.
/// </summary>
[MaxLength(64)]
[StringLength(64)]
public string AppName { get; set; }
/// <summary>
/// Gets or sets the app version.
/// </summary>
[MaxLength(32)]
[StringLength(32)]
public string AppVersion { get; set; }
/// <summary>
/// Gets or sets the device name.
/// </summary>
[MaxLength(64)]
[StringLength(64)]
public string DeviceName { get; set; }
/// <summary>
/// Gets or sets the device id.
/// </summary>
[MaxLength(256)]
[StringLength(256)]
public string DeviceId { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this device is active.
/// </summary>
public bool IsActive { get; set; }
/// <summary>
/// Gets or sets the date created.
/// </summary>
public DateTime DateCreated { get; set; }
/// <summary>
/// Gets or sets the date modified.
/// </summary>
public DateTime DateModified { get; set; }
/// <summary>
/// Gets or sets the date of last activity.
/// </summary>
public DateTime DateLastActivity { get; set; }
/// <summary>
/// Gets the user.
/// </summary>
public User User { get; private set; }
}
/// <summary>
/// Gets the id.
/// </summary>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the user id.
/// </summary>
public Guid UserId { get; private set; }
/// <summary>
/// Gets or sets the access token.
/// </summary>
public string AccessToken { get; set; }
/// <summary>
/// Gets or sets the app name.
/// </summary>
[MaxLength(64)]
[StringLength(64)]
public string AppName { get; set; }
/// <summary>
/// Gets or sets the app version.
/// </summary>
[MaxLength(32)]
[StringLength(32)]
public string AppVersion { get; set; }
/// <summary>
/// Gets or sets the device name.
/// </summary>
[MaxLength(64)]
[StringLength(64)]
public string DeviceName { get; set; }
/// <summary>
/// Gets or sets the device id.
/// </summary>
[MaxLength(256)]
[StringLength(256)]
public string DeviceId { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this device is active.
/// </summary>
public bool IsActive { get; set; }
/// <summary>
/// Gets or sets the date created.
/// </summary>
public DateTime DateCreated { get; set; }
/// <summary>
/// Gets or sets the date modified.
/// </summary>
public DateTime DateModified { get; set; }
/// <summary>
/// Gets or sets the date of last activity.
/// </summary>
public DateTime DateLastActivity { get; set; }
/// <summary>
/// Gets the user.
/// </summary>
public User User { get; private set; }
}
@@ -3,36 +3,37 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Entities.Security
using System.ComponentModel.DataAnnotations.Schema;
/// <summary>
/// An entity representing custom options for a device.
/// </summary>
public class DeviceOptions
{
using System.ComponentModel.DataAnnotations.Schema;
/// <summary>
/// Initializes a new instance of the <see cref="DeviceOptions"/> class.
/// An entity representing custom options for a device.
/// </summary>
/// <param name="deviceId">The device id.</param>
public DeviceOptions(string deviceId)
public class DeviceOptions
{
DeviceId = deviceId;
/// <summary>
/// Initializes a new instance of the <see cref="DeviceOptions"/> class.
/// </summary>
/// <param name="deviceId">The device id.</param>
public DeviceOptions(string deviceId)
{
this.DeviceId = deviceId;
}
/// <summary>
/// Gets the id.
/// </summary>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the device id.
/// </summary>
public string DeviceId { get; private set; }
/// <summary>
/// Gets or sets the custom name.
/// </summary>
public string? CustomName { get; set; }
}
/// <summary>
/// Gets the id.
/// </summary>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets the device id.
/// </summary>
public string DeviceId { get; private set; }
/// <summary>
/// Gets or sets the custom name.
/// </summary>
public string? CustomName { get; set; }
}
@@ -2,77 +2,78 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace Jellyfin.Database.Implementations.Entities;
using System;
using System.Text.Json.Serialization;
/// <summary>
/// An entity representing the metadata for a group of trickplay tiles.
/// </summary>
public class TrickplayInfo
namespace Jellyfin.Database.Implementations.Entities
{
/// <summary>
/// Gets or sets the id of the associated item.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public Guid ItemId { get; set; }
using System;
using System.Text.Json.Serialization;
/// <summary>
/// Gets or sets width of an individual thumbnail.
/// An entity representing the metadata for a group of trickplay tiles.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int Width { get; set; }
public class TrickplayInfo
{
/// <summary>
/// Gets or sets the id of the associated item.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public Guid ItemId { get; set; }
/// <summary>
/// Gets or sets height of an individual thumbnail.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int Height { get; set; }
/// <summary>
/// Gets or sets width of an individual thumbnail.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int Width { get; set; }
/// <summary>
/// Gets or sets amount of thumbnails per row.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int TileWidth { get; set; }
/// <summary>
/// Gets or sets height of an individual thumbnail.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int Height { get; set; }
/// <summary>
/// Gets or sets amount of thumbnails per column.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int TileHeight { get; set; }
/// <summary>
/// Gets or sets amount of thumbnails per row.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int TileWidth { get; set; }
/// <summary>
/// Gets or sets total amount of non-black thumbnails.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int ThumbnailCount { get; set; }
/// <summary>
/// Gets or sets amount of thumbnails per column.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int TileHeight { get; set; }
/// <summary>
/// Gets or sets interval in milliseconds between each trickplay thumbnail.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int Interval { get; set; }
/// <summary>
/// Gets or sets total amount of non-black thumbnails.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int ThumbnailCount { get; set; }
/// <summary>
/// Gets or sets peak bandwidth usage in bits per second.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int Bandwidth { get; set; }
/// <summary>
/// Gets or sets interval in milliseconds between each trickplay thumbnail.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int Interval { get; set; }
/// <summary>
/// Gets or sets peak bandwidth usage in bits per second.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int Bandwidth { get; set; }
}
}
@@ -2,343 +2,346 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1515 // Put constructor initializers on their own line
#pragma warning disable CA1724
namespace Jellyfin.Database.Implementations.Entities
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// An entity representing a user.
/// </summary>
public class User : IHasPermissions, IHasConcurrencyToken
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Database.Implementations.Interfaces;
/// <summary>
/// Initializes a new instance of the <see cref="User"/> class.
/// Public constructor with required data.
/// An entity representing a user.
/// </summary>
/// <param name="username">The username for the new user.</param>
/// <param name="authenticationProviderId">The Id of the user's authentication provider.</param>
/// <param name="passwordResetProviderId">The Id of the user's password reset provider.</param>
public User(string username, string authenticationProviderId, string passwordResetProviderId)
public class User : IHasPermissions, IHasConcurrencyToken
{
ArgumentException.ThrowIfNullOrEmpty(username);
ArgumentException.ThrowIfNullOrEmpty(authenticationProviderId);
ArgumentException.ThrowIfNullOrEmpty(passwordResetProviderId);
/// <summary>
/// Initializes a new instance of the <see cref="User"/> class.
/// Public constructor with required data.
/// </summary>
/// <param name="username">The username for the new user.</param>
/// <param name="authenticationProviderId">The Id of the user's authentication provider.</param>
/// <param name="passwordResetProviderId">The Id of the user's password reset provider.</param>
public User(string username, string authenticationProviderId, string passwordResetProviderId)
{
ArgumentException.ThrowIfNullOrEmpty(username);
ArgumentException.ThrowIfNullOrEmpty(authenticationProviderId);
ArgumentException.ThrowIfNullOrEmpty(passwordResetProviderId);
Username = username;
AuthenticationProviderId = authenticationProviderId;
PasswordResetProviderId = passwordResetProviderId;
this.Username = username;
this.AuthenticationProviderId = authenticationProviderId;
this.PasswordResetProviderId = passwordResetProviderId;
AccessSchedules = new HashSet<AccessSchedule>();
DisplayPreferences = new HashSet<DisplayPreferences>();
ItemDisplayPreferences = new HashSet<ItemDisplayPreferences>();
// Groups = new HashSet<Group>();
Permissions = new HashSet<Permission>();
Preferences = new HashSet<Preference>();
// ProviderMappings = new HashSet<ProviderMapping>();
this.AccessSchedules = new HashSet<AccessSchedule>();
this.DisplayPreferences = new HashSet<DisplayPreferences>();
this.ItemDisplayPreferences = new HashSet<ItemDisplayPreferences>();
// Groups = new HashSet<Group>();
this.Permissions = new HashSet<Permission>();
this.Preferences = new HashSet<Preference>();
// ProviderMappings = new HashSet<ProviderMapping>();
// Set default values
Id = Guid.NewGuid();
InvalidLoginAttemptCount = 0;
EnableUserPreferenceAccess = true;
MustUpdatePassword = false;
DisplayMissingEpisodes = false;
DisplayCollectionsView = false;
HidePlayedInLatest = true;
RememberAudioSelections = true;
RememberSubtitleSelections = true;
EnableNextEpisodeAutoPlay = true;
EnableAutoLogin = false;
PlayDefaultAudioTrack = true;
SubtitleMode = SubtitlePlaybackMode.Default;
SyncPlayAccess = SyncPlayUserAccessType.CreateAndJoinGroups;
}
// Set default values
this.Id = Guid.NewGuid();
this.InvalidLoginAttemptCount = 0;
this.EnableUserPreferenceAccess = true;
this.MustUpdatePassword = false;
this.DisplayMissingEpisodes = false;
this.DisplayCollectionsView = false;
this.HidePlayedInLatest = true;
this.RememberAudioSelections = true;
this.RememberSubtitleSelections = true;
this.EnableNextEpisodeAutoPlay = true;
this.EnableAutoLogin = false;
this.PlayDefaultAudioTrack = true;
this.SubtitleMode = SubtitlePlaybackMode.Default;
this.SyncPlayAccess = SyncPlayUserAccessType.CreateAndJoinGroups;
}
/// <summary>
/// Gets or sets the Id of the user.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
public Guid Id { get; set; }
/// <summary>
/// Gets or sets the Id of the user.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
public Guid Id { get; set; }
/// <summary>
/// Gets or sets the user's name.
/// </summary>
/// <remarks>
/// Required, Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string Username { get; set; }
/// <summary>
/// Gets or sets the user's name.
/// </summary>
/// <remarks>
/// Required, Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string Username { get; set; }
/// <summary>
/// Gets or sets the user's password, or <c>null</c> if none is set.
/// </summary>
/// <remarks>
/// Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string? Password { get; set; }
/// <summary>
/// Gets or sets the user's password, or <c>null</c> if none is set.
/// </summary>
/// <remarks>
/// Max length = 65535.
/// </remarks>
[MaxLength(65535)]
[StringLength(65535)]
public string? Password { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the user must update their password.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool MustUpdatePassword { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the user must update their password.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool MustUpdatePassword { get; set; }
/// <summary>
/// Gets or sets the audio language preference.
/// </summary>
/// <remarks>
/// Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string? AudioLanguagePreference { get; set; }
/// <summary>
/// Gets or sets the audio language preference.
/// </summary>
/// <remarks>
/// Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string? AudioLanguagePreference { get; set; }
/// <summary>
/// Gets or sets the authentication provider id.
/// </summary>
/// <remarks>
/// Required, Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string AuthenticationProviderId { get; set; }
/// <summary>
/// Gets or sets the authentication provider id.
/// </summary>
/// <remarks>
/// Required, Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string AuthenticationProviderId { get; set; }
/// <summary>
/// Gets or sets the password reset provider id.
/// </summary>
/// <remarks>
/// Required, Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string PasswordResetProviderId { get; set; }
/// <summary>
/// Gets or sets the password reset provider id.
/// </summary>
/// <remarks>
/// Required, Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string PasswordResetProviderId { get; set; }
/// <summary>
/// Gets or sets the invalid login attempt count.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int InvalidLoginAttemptCount { get; set; }
/// <summary>
/// Gets or sets the invalid login attempt count.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public int InvalidLoginAttemptCount { get; set; }
/// <summary>
/// Gets or sets the last activity date.
/// </summary>
public DateTime? LastActivityDate { get; set; }
/// <summary>
/// Gets or sets the last activity date.
/// </summary>
public DateTime? LastActivityDate { get; set; }
/// <summary>
/// Gets or sets the last login date.
/// </summary>
public DateTime? LastLoginDate { get; set; }
/// <summary>
/// Gets or sets the last login date.
/// </summary>
public DateTime? LastLoginDate { get; set; }
/// <summary>
/// Gets or sets the number of login attempts the user can make before they are locked out.
/// </summary>
public int? LoginAttemptsBeforeLockout { get; set; }
/// <summary>
/// Gets or sets the number of login attempts the user can make before they are locked out.
/// </summary>
public int? LoginAttemptsBeforeLockout { get; set; }
/// <summary>
/// Gets or sets the maximum number of active sessions the user can have at once.
/// </summary>
public int MaxActiveSessions { get; set; }
/// <summary>
/// Gets or sets the maximum number of active sessions the user can have at once.
/// </summary>
public int MaxActiveSessions { get; set; }
/// <summary>
/// Gets or sets the subtitle mode.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public SubtitlePlaybackMode SubtitleMode { get; set; }
/// <summary>
/// Gets or sets the subtitle mode.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public SubtitlePlaybackMode SubtitleMode { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the default audio track should be played.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool PlayDefaultAudioTrack { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the default audio track should be played.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool PlayDefaultAudioTrack { get; set; }
/// <summary>
/// Gets or sets the subtitle language preference.
/// </summary>
/// <remarks>
/// Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string? SubtitleLanguagePreference { get; set; }
/// <summary>
/// Gets or sets the subtitle language preference.
/// </summary>
/// <remarks>
/// Max length = 255.
/// </remarks>
[MaxLength(255)]
[StringLength(255)]
public string? SubtitleLanguagePreference { get; set; }
/// <summary>
/// Gets or sets a value indicating whether missing episodes should be displayed.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool DisplayMissingEpisodes { get; set; }
/// <summary>
/// Gets or sets a value indicating whether missing episodes should be displayed.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool DisplayMissingEpisodes { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to display the collections view.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool DisplayCollectionsView { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to display the collections view.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool DisplayCollectionsView { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the user has a local password.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool EnableLocalPassword { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the user has a local password.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool EnableLocalPassword { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the server should hide played content in "Latest".
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool HidePlayedInLatest { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the server should hide played content in "Latest".
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool HidePlayedInLatest { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to remember audio selections on played content.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool RememberAudioSelections { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to remember audio selections on played content.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool RememberAudioSelections { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to remember subtitle selections on played content.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool RememberSubtitleSelections { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to remember subtitle selections on played content.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool RememberSubtitleSelections { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to enable auto-play for the next episode.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool EnableNextEpisodeAutoPlay { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to enable auto-play for the next episode.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool EnableNextEpisodeAutoPlay { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the user should auto-login.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool EnableAutoLogin { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the user should auto-login.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool EnableAutoLogin { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the user can change their preferences.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool EnableUserPreferenceAccess { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the user can change their preferences.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public bool EnableUserPreferenceAccess { get; set; }
/// <summary>
/// Gets or sets the maximum parental rating score.
/// </summary>
public int? MaxParentalRatingScore { get; set; }
/// <summary>
/// Gets or sets the maximum parental rating score.
/// </summary>
public int? MaxParentalRatingScore { get; set; }
/// <summary>
/// Gets or sets the maximum parental rating sub score.
/// </summary>
public int? MaxParentalRatingSubScore { get; set; }
/// <summary>
/// Gets or sets the maximum parental rating sub score.
/// </summary>
public int? MaxParentalRatingSubScore { get; set; }
/// <summary>
/// Gets or sets the remote client bitrate limit.
/// </summary>
public int? RemoteClientBitrateLimit { get; set; }
/// <summary>
/// Gets or sets the remote client bitrate limit.
/// </summary>
public int? RemoteClientBitrateLimit { get; set; }
/// <summary>
/// Gets or sets the internal id.
/// This is a temporary stopgap for until the library db is migrated.
/// This corresponds to the value of the index of this user in the library db.
/// </summary>
public long InternalId { get; set; }
/// <summary>
/// Gets or sets the internal id.
/// This is a temporary stopgap for until the library db is migrated.
/// This corresponds to the value of the index of this user in the library db.
/// </summary>
public long InternalId { get; set; }
/// <summary>
/// Gets or sets the user's profile image. Can be <c>null</c>.
/// </summary>
// [ForeignKey("UserId")]
public virtual ImageInfo? ProfileImage { get; set; }
/// <summary>
/// Gets or sets the user's profile image. Can be <c>null</c>.
/// </summary>
// [ForeignKey("UserId")]
public virtual ImageInfo? ProfileImage { get; set; }
/// <summary>
/// Gets the user's display preferences.
/// </summary>
public virtual ICollection<DisplayPreferences> DisplayPreferences { get; private set; }
/// <summary>
/// Gets the user's display preferences.
/// </summary>
public virtual ICollection<DisplayPreferences> DisplayPreferences { get; private set; }
/// <summary>
/// Gets or sets the level of sync play permissions this user has.
/// </summary>
public SyncPlayUserAccessType SyncPlayAccess { get; set; }
/// <summary>
/// Gets or sets the level of sync play permissions this user has.
/// </summary>
public SyncPlayUserAccessType SyncPlayAccess { get; set; }
/// <summary>
/// Gets or sets the cast receiver id.
/// </summary>
[StringLength(32)]
public string? CastReceiverId { get; set; }
/// <summary>
/// Gets or sets the cast receiver id.
/// </summary>
[StringLength(32)]
public string? CastReceiverId { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets the list of access schedules this user has.
/// </summary>
public virtual ICollection<AccessSchedule> AccessSchedules { get; private set; }
/// <summary>
/// Gets the list of access schedules this user has.
/// </summary>
public virtual ICollection<AccessSchedule> AccessSchedules { get; private set; }
/// <summary>
/// Gets the list of item display preferences.
/// </summary>
public virtual ICollection<ItemDisplayPreferences> ItemDisplayPreferences { get; private set; }
/// <summary>
/// Gets the list of item display preferences.
/// </summary>
public virtual ICollection<ItemDisplayPreferences> ItemDisplayPreferences { get; private set; }
/*
/// <summary>
/// Gets the list of groups this user is a member of.
/// </summary>
public virtual ICollection<Group> Groups { get; private set; }
*/
/*
/// <summary>
/// Gets the list of groups this user is a member of.
/// </summary>
public virtual ICollection<Group> Groups { get; private set; }
*/
/// <summary>
/// Gets the list of permissions this user has.
/// </summary>
[ForeignKey("Permission_Permissions_Guid")]
public virtual ICollection<Permission> Permissions { get; private set; }
/// <summary>
/// Gets the list of permissions this user has.
/// </summary>
[ForeignKey("Permission_Permissions_Guid")]
public virtual ICollection<Permission> Permissions { get; private set; }
/*
/// <summary>
/// Gets the list of provider mappings this user has.
/// </summary>
public virtual ICollection<ProviderMapping> ProviderMappings { get; private set; }
*/
/*
/// <summary>
/// Gets the list of provider mappings this user has.
/// </summary>
public virtual ICollection<ProviderMapping> ProviderMappings { get; private set; }
*/
/// <summary>
/// Gets the list of preferences this user has.
/// </summary>
[ForeignKey("Preference_Preferences_Guid")]
public virtual ICollection<Preference> Preferences { get; private set; }
/// <summary>
/// Gets the list of preferences this user has.
/// </summary>
[ForeignKey("Preference_Preferences_Guid")]
public virtual ICollection<Preference> Preferences { get; private set; }
/// <inheritdoc/>
public void OnSavingChanges()
{
RowVersion++;
/// <inheritdoc/>
public void OnSavingChanges()
{
this.RowVersion++;
}
}
}
@@ -2,99 +2,102 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace Jellyfin.Database.Implementations.Entities;
#pragma warning disable CA1724
using System;
/// <summary>
/// Provides <see cref="BaseItemEntity"/> and <see cref="User"/> related data.
/// </summary>
public class UserData
namespace Jellyfin.Database.Implementations.Entities
{
/// <summary>
/// Gets or sets the custom data key.
/// </summary>
/// <value>The rating.</value>
public required string CustomDataKey { get; set; }
using System;
/// <summary>
/// Gets or sets the users 0-10 rating.
/// Provides <see cref="BaseItemEntity"/> and <see cref="User"/> related data.
/// </summary>
/// <value>The rating.</value>
public double? Rating { get; set; }
public class UserData
{
/// <summary>
/// Gets or sets the custom data key.
/// </summary>
/// <value>The rating.</value>
public required string CustomDataKey { get; set; }
/// <summary>
/// Gets or sets the playback position ticks.
/// </summary>
/// <value>The playback position ticks.</value>
public long PlaybackPositionTicks { get; set; }
/// <summary>
/// Gets or sets the users 0-10 rating.
/// </summary>
/// <value>The rating.</value>
public double? Rating { get; set; }
/// <summary>
/// Gets or sets the play count.
/// </summary>
/// <value>The play count.</value>
public int PlayCount { get; set; }
/// <summary>
/// Gets or sets the playback position ticks.
/// </summary>
/// <value>The playback position ticks.</value>
public long PlaybackPositionTicks { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is favorite.
/// </summary>
/// <value><c>true</c> if this instance is favorite; otherwise, <c>false</c>.</value>
public bool IsFavorite { get; set; }
/// <summary>
/// Gets or sets the play count.
/// </summary>
/// <value>The play count.</value>
public int PlayCount { get; set; }
/// <summary>
/// Gets or sets the last played date.
/// </summary>
/// <value>The last played date.</value>
public DateTime? LastPlayedDate { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is favorite.
/// </summary>
/// <value><c>true</c> if this instance is favorite; otherwise, <c>false</c>.</value>
public bool IsFavorite { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this <see cref="UserData" /> is played.
/// </summary>
/// <value><c>true</c> if played; otherwise, <c>false</c>.</value>
public bool Played { get; set; }
/// <summary>
/// Gets or sets the last played date.
/// </summary>
/// <value>The last played date.</value>
public DateTime? LastPlayedDate { get; set; }
/// <summary>
/// Gets or sets the index of the audio stream.
/// </summary>
/// <value>The index of the audio stream.</value>
public int? AudioStreamIndex { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this <see cref="UserData" /> is played.
/// </summary>
/// <value><c>true</c> if played; otherwise, <c>false</c>.</value>
public bool Played { get; set; }
/// <summary>
/// Gets or sets the index of the subtitle stream.
/// </summary>
/// <value>The index of the subtitle stream.</value>
public int? SubtitleStreamIndex { get; set; }
/// <summary>
/// Gets or sets the index of the audio stream.
/// </summary>
/// <value>The index of the audio stream.</value>
public int? AudioStreamIndex { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the item is liked or not.
/// This should never be serialized.
/// </summary>
/// <value><c>null</c> if [likes] contains no value, <c>true</c> if [likes]; otherwise, <c>false</c>.</value>
public bool? Likes { get; set; }
/// <summary>
/// Gets or sets the index of the subtitle stream.
/// </summary>
/// <value>The index of the subtitle stream.</value>
public int? SubtitleStreamIndex { get; set; }
/// <summary>
/// Gets or Sets the date the referenced <see cref="Item"/> has been deleted.
/// </summary>
public DateTime? RetentionDate { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the item is liked or not.
/// This should never be serialized.
/// </summary>
/// <value><c>null</c> if [likes] contains no value, <c>true</c> if [likes]; otherwise, <c>false</c>.</value>
public bool? Likes { get; set; }
/// <summary>
/// Gets or sets the key.
/// </summary>
/// <value>The key.</value>
public required Guid ItemId { get; set; }
/// <summary>
/// Gets or Sets the date the referenced <see cref="Item"/> has been deleted.
/// </summary>
public DateTime? RetentionDate { get; set; }
/// <summary>
/// Gets or Sets the BaseItem.
/// </summary>
public required BaseItemEntity? Item { get; set; }
/// <summary>
/// Gets or sets the key.
/// </summary>
/// <value>The key.</value>
public required Guid ItemId { get; set; }
/// <summary>
/// Gets or Sets the UserId.
/// </summary>
public required Guid UserId { get; set; }
/// <summary>
/// Gets or Sets the BaseItem.
/// </summary>
public required BaseItemEntity? Item { get; set; }
/// <summary>
/// Gets or Sets the User.
/// </summary>
public required User? User { get; set; }
/// <summary>
/// Gets or Sets the UserId.
/// </summary>
public required Guid UserId { get; set; }
/// <summary>
/// Gets or Sets the User.
/// </summary>
public required User? User { get; set; }
}
}
@@ -57,5 +57,5 @@ public enum HomeSectionType
/// <summary>
/// Continue Reading.
/// </summary>
ResumeBook = 9
ResumeBook = 9,
}
@@ -3,17 +3,18 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Interfaces
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Entities.Libraries;
/// <summary>
/// An interface abstracting an entity that has artwork.
/// </summary>
public interface IHasArtwork
{
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Entities.Libraries;
/// <summary>
/// Gets a collection containing this entity's artwork.
/// An interface abstracting an entity that has artwork.
/// </summary>
ICollection<Artwork> Artwork { get; }
public interface IHasArtwork
{
/// <summary>
/// Gets a collection containing this entity's artwork.
/// </summary>
ICollection<Artwork> Artwork { get; }
}
}
@@ -3,17 +3,18 @@
// </copyright>
namespace Jellyfin.Database.Implementations.Interfaces
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Entities.Libraries;
/// <summary>
/// An abstraction representing an entity that has companies.
/// </summary>
public interface IHasCompanies
{
using System.Collections.Generic;
using Jellyfin.Database.Implementations.Entities.Libraries;
/// <summary>
/// Gets a collection containing this entity's companies.
/// An abstraction representing an entity that has companies.
/// </summary>
ICollection<Company> Companies { get; }
public interface IHasCompanies
{
/// <summary>
/// Gets a collection containing this entity's companies.
/// </summary>
ICollection<Company> Companies { get; }
}
}
@@ -37,3 +37,4 @@
</ItemGroup>
</Project>
@@ -2,6 +2,9 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value null
#pragma warning disable CS0649 // Assignment made to same variable
namespace Jellyfin.Database.Implementations;
/// <summary>
@@ -20,7 +23,7 @@ public sealed class JellyfinDatabaseProviderKeyAttribute : System.Attribute
/// <param name="databaseProviderKey">The key on which to identify the annotated provider.</param>
public JellyfinDatabaseProviderKeyAttribute(string databaseProviderKey)
{
databaseProviderKey = databaseProviderKey;
this.databaseProviderKey = databaseProviderKey;
}
/// <summary>
@@ -28,6 +31,6 @@ public sealed class JellyfinDatabaseProviderKeyAttribute : System.Attribute
/// </summary>
public string DatabaseProviderKey
{
get { return databaseProviderKey; }
get { return this.databaseProviderKey; }
}
}
@@ -2,6 +2,8 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1202
namespace Jellyfin.Database.Implementations;
using System;
@@ -17,7 +19,6 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.Logging;
/// <inheritdoc/>
/// <summary>
/// Initializes a new instance of the <see cref="JellyfinDbContext"/> class.
@@ -28,150 +29,156 @@ using Microsoft.Extensions.Logging;
/// <param name="entityFrameworkCoreLocking">The locking behavior.</param>
public class JellyfinDbContext(DbContextOptions<JellyfinDbContext> options, ILogger<JellyfinDbContext> logger, IJellyfinDatabaseProvider jellyfinDatabaseProvider, IEntityFrameworkCoreLockingBehavior entityFrameworkCoreLocking) : DbContext(options)
{
private static readonly Action<ILogger, Exception?> SaveChangesError =
LoggerMessage.Define(
LogLevel.Error,
new EventId(1, nameof(SaveChanges)),
"Error trying to save changes.");
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the access schedules.
/// </summary>
public DbSet<AccessSchedule> AccessSchedules => Set<AccessSchedule>();
public DbSet<AccessSchedule> AccessSchedules => this.Set<AccessSchedule>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the activity logs.
/// </summary>
public DbSet<ActivityLog> ActivityLogs => Set<ActivityLog>();
public DbSet<ActivityLog> ActivityLogs => this.Set<ActivityLog>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the API keys.
/// </summary>
public DbSet<ApiKey> ApiKeys => Set<ApiKey>();
public DbSet<ApiKey> ApiKeys => this.Set<ApiKey>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the devices.
/// </summary>
public DbSet<Device> Devices => Set<Device>();
public DbSet<Device> Devices => this.Set<Device>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the device options.
/// </summary>
public DbSet<DeviceOptions> DeviceOptions => Set<DeviceOptions>();
public DbSet<DeviceOptions> DeviceOptions => this.Set<DeviceOptions>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the display preferences.
/// </summary>
public DbSet<DisplayPreferences> DisplayPreferences => Set<DisplayPreferences>();
public DbSet<DisplayPreferences> DisplayPreferences => this.Set<DisplayPreferences>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the image infos.
/// </summary>
public DbSet<ImageInfo> ImageInfos => Set<ImageInfo>();
public DbSet<ImageInfo> ImageInfos => this.Set<ImageInfo>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the item display preferences.
/// </summary>
public DbSet<ItemDisplayPreferences> ItemDisplayPreferences => Set<ItemDisplayPreferences>();
public DbSet<ItemDisplayPreferences> ItemDisplayPreferences => this.Set<ItemDisplayPreferences>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the custom item display preferences.
/// </summary>
public DbSet<CustomItemDisplayPreferences> CustomItemDisplayPreferences => Set<CustomItemDisplayPreferences>();
public DbSet<CustomItemDisplayPreferences> CustomItemDisplayPreferences => this.Set<CustomItemDisplayPreferences>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the permissions.
/// </summary>
public DbSet<Permission> Permissions => Set<Permission>();
public DbSet<Permission> Permissions => this.Set<Permission>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the preferences.
/// </summary>
public DbSet<Preference> Preferences => Set<Preference>();
public DbSet<Preference> Preferences => this.Set<Preference>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the users.
/// </summary>
public DbSet<User> Users => Set<User>();
public DbSet<User> Users => this.Set<User>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the trickplay metadata.
/// </summary>
public DbSet<TrickplayInfo> TrickplayInfos => Set<TrickplayInfo>();
public DbSet<TrickplayInfo> TrickplayInfos => this.Set<TrickplayInfo>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the media segments.
/// </summary>
public DbSet<MediaSegment> MediaSegments => Set<MediaSegment>();
public DbSet<MediaSegment> MediaSegments => this.Set<MediaSegment>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the user data.
/// </summary>
public DbSet<UserData> UserData => Set<UserData>();
public DbSet<UserData> UserData => this.Set<UserData>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the user data.
/// </summary>
public DbSet<AncestorId> AncestorIds => Set<AncestorId>();
public DbSet<AncestorId> AncestorIds => this.Set<AncestorId>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the user data.
/// </summary>
public DbSet<AttachmentStreamInfo> AttachmentStreamInfos => Set<AttachmentStreamInfo>();
public DbSet<AttachmentStreamInfo> AttachmentStreamInfos => this.Set<AttachmentStreamInfo>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the user data.
/// </summary>
public DbSet<BaseItemEntity> BaseItems => Set<BaseItemEntity>();
public DbSet<BaseItemEntity> BaseItems => this.Set<BaseItemEntity>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the user data.
/// </summary>
public DbSet<Chapter> Chapters => Set<Chapter>();
public DbSet<Chapter> Chapters => this.Set<Chapter>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<ItemValue> ItemValues => Set<ItemValue>();
public DbSet<ItemValue> ItemValues => this.Set<ItemValue>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<ItemValueMap> ItemValuesMap => Set<ItemValueMap>();
public DbSet<ItemValueMap> ItemValuesMap => this.Set<ItemValueMap>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<MediaStreamInfo> MediaStreamInfos => Set<MediaStreamInfo>();
public DbSet<MediaStreamInfo> MediaStreamInfos => this.Set<MediaStreamInfo>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<People> Peoples => Set<People>();
public DbSet<People> Peoples => this.Set<People>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<PeopleBaseItemMap> PeopleBaseItemMap => Set<PeopleBaseItemMap>();
public DbSet<PeopleBaseItemMap> PeopleBaseItemMap => this.Set<PeopleBaseItemMap>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/> containing the referenced Providers with ids.
/// </summary>
public DbSet<BaseItemProvider> BaseItemProviders => Set<BaseItemProvider>();
public DbSet<BaseItemProvider> BaseItemProviders => this.Set<BaseItemProvider>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<BaseItemImageInfo> BaseItemImageInfos => Set<BaseItemImageInfo>();
public DbSet<BaseItemImageInfo> BaseItemImageInfos => this.Set<BaseItemImageInfo>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<BaseItemMetadataField> BaseItemMetadataFields => Set<BaseItemMetadataField>();
public DbSet<BaseItemMetadataField> BaseItemMetadataFields => this.Set<BaseItemMetadataField>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<BaseItemTrailerType> BaseItemTrailerTypes => Set<BaseItemTrailerType>();
public DbSet<BaseItemTrailerType> BaseItemTrailerTypes => this.Set<BaseItemTrailerType>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<KeyframeData> KeyframeData => Set<KeyframeData>();
public DbSet<KeyframeData> KeyframeData => this.Set<KeyframeData>();
/*public DbSet<Artwork> Artwork => Set<Artwork>();
@@ -262,7 +269,7 @@ public class JellyfinDbContext(DbContextOptions<JellyfinDbContext> options, ILog
bool acceptAllChangesOnSuccess,
CancellationToken cancellationToken = default)
{
HandleConcurrencyToken();
this.HandleConcurrencyToken();
try
{
@@ -275,7 +282,7 @@ public class JellyfinDbContext(DbContextOptions<JellyfinDbContext> options, ILog
}
catch (Exception e)
{
logger.LogError(e, "Error trying to save changes.");
SaveChangesError(logger, e);
throw;
}
}
@@ -283,7 +290,7 @@ public class JellyfinDbContext(DbContextOptions<JellyfinDbContext> options, ILog
/// <inheritdoc/>
public override int SaveChanges(bool acceptAllChangesOnSuccess) // SaveChanges(bool) is beeing called by SaveChanges() with default to false.
{
HandleConcurrencyToken();
this.HandleConcurrencyToken();
try
{
@@ -296,14 +303,14 @@ public class JellyfinDbContext(DbContextOptions<JellyfinDbContext> options, ILog
}
catch (Exception e)
{
logger.LogError(e, "Error trying to save changes.");
SaveChangesError(logger, e);
throw;
}
}
private void HandleConcurrencyToken()
{
foreach (var saveEntity in ChangeTracker.Entries()
foreach (var saveEntity in this.ChangeTracker.Entries()
.Where(e => e.State == EntityState.Modified)
.Select(entry => entry.Entity)
.OfType<IHasConcurrencyToken>())
@@ -318,6 +325,8 @@ public class JellyfinDbContext(DbContextOptions<JellyfinDbContext> options, ILog
jellyfinDatabaseProvider.OnModelCreating(modelBuilder);
base.OnModelCreating(modelBuilder);
ArgumentNullException.ThrowIfNull(modelBuilder);
// Configuration for each entity is in its own class inside 'ModelConfiguration'.
modelBuilder.ApplyConfigurationsFromAssembly(typeof(JellyfinDbContext).Assembly);
}
@@ -3,6 +3,10 @@
// </copyright>
#pragma warning disable RS0030 // Do not use banned APIs
#pragma warning disable SA1309 // Variable should not begin with underscore
#pragma warning disable SA1600 // Elements should be documented
#pragma warning disable CA1062 // Validate arguments of public methods
#pragma warning disable SA1128 // Put constructor initializers on their own line
namespace Jellyfin.Database.Implementations;
@@ -129,6 +133,7 @@ public static class JellyfinQueryHelperExtensions
property = ParameterReplacer.Replace<Func<TEntity, TProperty>, Func<TEntity, TProperty>>(property, property.Parameters[0], parameter);
if (oneOf.Count == 1)
{
ArgumentNullException.ThrowIfNull(property);
var value = oneOf[0];
if (typeof(TProperty).IsValueType)
{
@@ -142,7 +147,7 @@ public static class JellyfinQueryHelperExtensions
var containsMethodInfo = _containsQueryCache.GetOrAdd(typeof(TProperty), static (key) => _containsMethodGenericCache.MakeGenericMethod(key));
if (oneOf.Count < 4) // arbitrary value choosen.
if (oneOf.Count < 4)
{
// if we have 3 or fewer values to check against its faster to do a IN(const,const,const) lookup
return Expression.Lambda<Func<TEntity, bool>>(Expression.Call(null, containsMethodInfo, Expression.Constant(oneOf), property.Body), parameter);
@@ -171,27 +176,27 @@ public static class JellyfinQueryHelperExtensions
public ParameterReplacerVisitor(ParameterExpression source, ParameterExpression target)
{
_source = source;
_target = target;
this._source = source;
this._target = target;
}
internal Expression<TOutput> VisitAndConvert<T>(Expression<T> root)
{
return (Expression<TOutput>)VisitLambda(root);
return (Expression<TOutput>)this.VisitLambda(root);
}
protected override Expression VisitLambda<T>(Expression<T> node)
{
// Leave all parameters alone except the one we want to replace.
var parameters = node.Parameters.Select(p => p == _source ? _target : p);
var parameters = node.Parameters.Select(p => p == this._source ? this._target : p);
return Expression.Lambda<TOutput>(Visit(node.Body), parameters);
return Expression.Lambda<TOutput>(this.Visit(node.Body), parameters);
}
protected override Expression VisitParameter(ParameterExpression node)
{
// Replace the source with the target, visit other params as usual.
return node == _source ? _target : base.VisitParameter(node);
return node == this._source ? this._target : base.VisitParameter(node);
}
}
}
@@ -2,6 +2,9 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1309 // VAriables should not begin with underscore
#pragma warning disable CA1848 // VAriables should not begin with underscore
namespace Jellyfin.Database.Implementations.Locking;
using System;
@@ -22,24 +25,26 @@ public class NoLockBehavior : IEntityFrameworkCoreLockingBehavior
/// <param name="logger">The Application logger.</param>
public NoLockBehavior(ILogger<NoLockBehavior> logger)
{
_logger = logger;
this._logger = logger;
}
/// <inheritdoc/>
public void OnSaveChanges(JellyfinDbContext context, Action saveChanges)
{
ArgumentNullException.ThrowIfNull(saveChanges);
saveChanges();
}
/// <inheritdoc/>
public void Initialise(DbContextOptionsBuilder optionsBuilder)
{
_logger.LogInformation("The database locking mode has been set to: NoLock.");
this._logger.LogInformation("The database locking mode has been set to: NoLock.");
}
/// <inheritdoc/>
public async Task OnSaveChangesAsync(JellyfinDbContext context, Func<Task> saveChanges)
{
ArgumentNullException.ThrowIfNull(saveChanges);
await saveChanges().ConfigureAwait(false);
}
}
@@ -4,7 +4,10 @@
namespace Jellyfin.Database.Implementations.Locking;
#pragma warning disable IDISP004
#pragma warning disable CA1873
#pragma warning disable CA1848
#pragma warning disable SA1309 // Variables should not begin with underscore
using System;
using System.Data.Common;
@@ -56,13 +59,13 @@ public class OptimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
return backoff + TimeSpan.FromMilliseconds(RandomNumberGenerator.GetInt32(0, (int)(backoff.TotalMilliseconds * .5)));
};
_logger = logger;
_writePolicy = Policy
this._logger = logger;
this._writePolicy = Policy
.HandleInner<Exception>(e =>
e.Message.Contains("database is locked", StringComparison.InvariantCultureIgnoreCase) ||
e.Message.Contains("database table is locked", StringComparison.InvariantCultureIgnoreCase))
.WaitAndRetry(sleepDurations.Length, backoffProvider, RetryHandle);
_writeAsyncPolicy = Policy
this._writeAsyncPolicy = Policy
.HandleInner<Exception>(e =>
e.Message.Contains("database is locked", StringComparison.InvariantCultureIgnoreCase) ||
e.Message.Contains("database table is locked", StringComparison.InvariantCultureIgnoreCase))
@@ -72,11 +75,11 @@ public class OptimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
{
if (retryNo < sleepDurations.Length)
{
_logger.LogWarning("Operation failed retry {RetryNo}", retryNo);
this._logger.LogWarning("Operation failed retry {RetryNo}", retryNo);
}
else
{
_logger.LogError(exception, "Operation failed retry {RetryNo}", retryNo);
this._logger.LogError(exception, "Operation failed retry {RetryNo}", retryNo);
}
}
}
@@ -84,21 +87,22 @@ public class OptimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
/// <inheritdoc/>
public void Initialise(DbContextOptionsBuilder optionsBuilder)
{
_logger.LogInformation("The database locking mode has been set to: Optimistic.");
optionsBuilder.AddInterceptors(new RetryInterceptor(_writeAsyncPolicy, _writePolicy));
optionsBuilder.AddInterceptors(new TransactionLockingInterceptor(_writeAsyncPolicy, _writePolicy));
this._logger.LogInformation("The database locking mode has been set to: Optimistic.");
ArgumentNullException.ThrowIfNull(optionsBuilder);
optionsBuilder.AddInterceptors(new RetryInterceptor(this._writeAsyncPolicy, this._writePolicy));
optionsBuilder.AddInterceptors(new TransactionLockingInterceptor(this._writeAsyncPolicy, this._writePolicy));
}
/// <inheritdoc/>
public void OnSaveChanges(JellyfinDbContext context, Action saveChanges)
{
_writePolicy.ExecuteAndCapture(saveChanges);
this._writePolicy.ExecuteAndCapture(saveChanges);
}
/// <inheritdoc/>
public async Task OnSaveChangesAsync(JellyfinDbContext context, Func<Task> saveChanges)
{
await _writeAsyncPolicy.ExecuteAndCaptureAsync(saveChanges).ConfigureAwait(false);
await this._writeAsyncPolicy.ExecuteAndCaptureAsync(saveChanges).ConfigureAwait(false);
}
private sealed class TransactionLockingInterceptor : DbTransactionInterceptor
@@ -108,18 +112,18 @@ public class OptimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
public TransactionLockingInterceptor(AsyncPolicy asyncRetryPolicy, Policy retryPolicy)
{
_asyncRetryPolicy = asyncRetryPolicy;
_retryPolicy = retryPolicy;
this._asyncRetryPolicy = asyncRetryPolicy;
this._retryPolicy = retryPolicy;
}
public override InterceptionResult<DbTransaction> TransactionStarting(DbConnection connection, TransactionStartingEventData eventData, InterceptionResult<DbTransaction> result)
{
return InterceptionResult<DbTransaction>.SuppressWithResult(_retryPolicy.Execute(() => connection.BeginTransaction(eventData.IsolationLevel)));
return InterceptionResult<DbTransaction>.SuppressWithResult(this._retryPolicy.Execute(() => connection.BeginTransaction(eventData.IsolationLevel)));
}
public override async ValueTask<InterceptionResult<DbTransaction>> TransactionStartingAsync(DbConnection connection, TransactionStartingEventData eventData, InterceptionResult<DbTransaction> result, CancellationToken cancellationToken = default)
{
return InterceptionResult<DbTransaction>.SuppressWithResult(await _asyncRetryPolicy.ExecuteAsync(async () => await connection.BeginTransactionAsync(eventData.IsolationLevel, cancellationToken).ConfigureAwait(false)).ConfigureAwait(false));
return InterceptionResult<DbTransaction>.SuppressWithResult(await this._asyncRetryPolicy.ExecuteAsync(async () => await connection.BeginTransactionAsync(eventData.IsolationLevel, cancellationToken).ConfigureAwait(false)).ConfigureAwait(false));
}
}
@@ -130,38 +134,38 @@ public class OptimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
public RetryInterceptor(AsyncPolicy asyncRetryPolicy, Policy retryPolicy)
{
_asyncRetryPolicy = asyncRetryPolicy;
_retryPolicy = retryPolicy;
this._asyncRetryPolicy = asyncRetryPolicy;
this._retryPolicy = retryPolicy;
}
public override InterceptionResult<int> NonQueryExecuting(DbCommand command, CommandEventData eventData, InterceptionResult<int> result)
{
return InterceptionResult<int>.SuppressWithResult(_retryPolicy.Execute(command.ExecuteNonQuery));
return InterceptionResult<int>.SuppressWithResult(this._retryPolicy.Execute(command.ExecuteNonQuery));
}
public override async ValueTask<InterceptionResult<int>> NonQueryExecutingAsync(DbCommand command, CommandEventData eventData, InterceptionResult<int> result, CancellationToken cancellationToken = default)
{
return InterceptionResult<int>.SuppressWithResult(await _asyncRetryPolicy.ExecuteAsync(async () => await command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false)).ConfigureAwait(false));
return InterceptionResult<int>.SuppressWithResult(await this._asyncRetryPolicy.ExecuteAsync(async () => await command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false)).ConfigureAwait(false));
}
public override InterceptionResult<object> ScalarExecuting(DbCommand command, CommandEventData eventData, InterceptionResult<object> result)
{
return InterceptionResult<object>.SuppressWithResult(_retryPolicy.Execute(() => command.ExecuteScalar()!));
return InterceptionResult<object>.SuppressWithResult(this._retryPolicy.Execute(() => command.ExecuteScalar()!));
}
public override async ValueTask<InterceptionResult<object>> ScalarExecutingAsync(DbCommand command, CommandEventData eventData, InterceptionResult<object> result, CancellationToken cancellationToken = default)
{
return InterceptionResult<object>.SuppressWithResult((await _asyncRetryPolicy.ExecuteAsync(async () => await command.ExecuteScalarAsync(cancellationToken).ConfigureAwait(false)!).ConfigureAwait(false))!);
return InterceptionResult<object>.SuppressWithResult((await this._asyncRetryPolicy.ExecuteAsync(async () => await command.ExecuteScalarAsync(cancellationToken).ConfigureAwait(false)!).ConfigureAwait(false))!);
}
public override InterceptionResult<DbDataReader> ReaderExecuting(DbCommand command, CommandEventData eventData, InterceptionResult<DbDataReader> result)
{
return InterceptionResult<DbDataReader>.SuppressWithResult(_retryPolicy.Execute(command.ExecuteReader));
return InterceptionResult<DbDataReader>.SuppressWithResult(this._retryPolicy.Execute(command.ExecuteReader));
}
public override async ValueTask<InterceptionResult<DbDataReader>> ReaderExecutingAsync(DbCommand command, CommandEventData eventData, InterceptionResult<DbDataReader> result, CancellationToken cancellationToken = default)
{
return InterceptionResult<DbDataReader>.SuppressWithResult(await _asyncRetryPolicy.ExecuteAsync(async () => await command.ExecuteReaderAsync(cancellationToken).ConfigureAwait(false)).ConfigureAwait(false));
return InterceptionResult<DbDataReader>.SuppressWithResult(await this._asyncRetryPolicy.ExecuteAsync(async () => await command.ExecuteReaderAsync(cancellationToken).ConfigureAwait(false)).ConfigureAwait(false));
}
}
}
@@ -7,6 +7,9 @@ namespace Jellyfin.Database.Implementations.Locking;
#pragma warning disable MT1013 // Releasing lock without guarantee of execution
#pragma warning disable MT1012 // Acquiring lock without guarantee of releasing
#pragma warning disable CA1873
#pragma warning disable IDISP004
#pragma warning disable CA1848
#pragma warning disable SA1309 // Variables should not begin with underscore
using System;
using System.Data;
@@ -17,6 +20,7 @@ using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
/// <summary>
/// A locking behavior that will always block any operation while a write is requested. Mimicks the old SqliteRepository behavior.
@@ -33,8 +37,8 @@ public class PessimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
/// <param name="loggerFactory">The logger factory.</param>
public PessimisticLockBehavior(ILogger<PessimisticLockBehavior> logger, ILoggerFactory loggerFactory)
{
_logger = logger;
_loggerFactory = loggerFactory;
this._logger = logger;
this._loggerFactory = loggerFactory;
}
private static ReaderWriterLockSlim DatabaseLock { get; } = new(LockRecursionPolicy.SupportsRecursion);
@@ -42,8 +46,9 @@ public class PessimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
/// <inheritdoc/>
public void OnSaveChanges(JellyfinDbContext context, Action saveChanges)
{
using (DbLock.EnterWrite(_logger))
using (DbLock.EnterWrite(this._logger))
{
ArgumentNullException.ThrowIfNull(saveChanges);
saveChanges();
}
}
@@ -51,16 +56,18 @@ public class PessimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
/// <inheritdoc/>
public void Initialise(DbContextOptionsBuilder optionsBuilder)
{
_logger.LogInformation("The database locking mode has been set to: Pessimistic.");
optionsBuilder.AddInterceptors(new CommandLockingInterceptor(_loggerFactory.CreateLogger<CommandLockingInterceptor>()));
optionsBuilder.AddInterceptors(new TransactionLockingInterceptor(_loggerFactory.CreateLogger<TransactionLockingInterceptor>()));
this._logger.LogInformation("The database locking mode has been set to: Pessimistic.");
ArgumentNullException.ThrowIfNull(optionsBuilder);
optionsBuilder.AddInterceptors(new CommandLockingInterceptor(this._loggerFactory.CreateLogger<CommandLockingInterceptor>()));
optionsBuilder.AddInterceptors(new TransactionLockingInterceptor(this._loggerFactory.CreateLogger<TransactionLockingInterceptor>()));
}
/// <inheritdoc/>
public async Task OnSaveChangesAsync(JellyfinDbContext context, Func<Task> saveChanges)
{
using (DbLock.EnterWrite(_logger))
using (DbLock.EnterWrite(this._logger))
{
ArgumentNullException.ThrowIfNull(saveChanges);
await saveChanges().ConfigureAwait(false);
}
}
@@ -71,61 +78,61 @@ public class PessimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
public TransactionLockingInterceptor(ILogger logger)
{
_logger = logger;
this._logger = logger;
}
public override InterceptionResult<DbTransaction> TransactionStarting(DbConnection connection, TransactionStartingEventData eventData, InterceptionResult<DbTransaction> result)
{
DbLock.BeginWriteLock(_logger);
DbLock.BeginWriteLock(this._logger);
return base.TransactionStarting(connection, eventData, result);
}
public override ValueTask<InterceptionResult<DbTransaction>> TransactionStartingAsync(DbConnection connection, TransactionStartingEventData eventData, InterceptionResult<DbTransaction> result, CancellationToken cancellationToken = default)
{
DbLock.BeginWriteLock(_logger);
DbLock.BeginWriteLock(this._logger);
return base.TransactionStartingAsync(connection, eventData, result, cancellationToken);
}
public override void TransactionCommitted(DbTransaction transaction, TransactionEndEventData eventData)
{
DbLock.EndWriteLock(_logger);
DbLock.EndWriteLock(this._logger);
base.TransactionCommitted(transaction, eventData);
}
public override Task TransactionCommittedAsync(DbTransaction transaction, TransactionEndEventData eventData, CancellationToken cancellationToken = default)
{
DbLock.EndWriteLock(_logger);
DbLock.EndWriteLock(this._logger);
return base.TransactionCommittedAsync(transaction, eventData, cancellationToken);
}
public override void TransactionFailed(DbTransaction transaction, TransactionErrorEventData eventData)
{
DbLock.EndWriteLock(_logger);
DbLock.EndWriteLock(this._logger);
base.TransactionFailed(transaction, eventData);
}
public override Task TransactionFailedAsync(DbTransaction transaction, TransactionErrorEventData eventData, CancellationToken cancellationToken = default)
{
DbLock.EndWriteLock(_logger);
DbLock.EndWriteLock(this._logger);
return base.TransactionFailedAsync(transaction, eventData, cancellationToken);
}
public override void TransactionRolledBack(DbTransaction transaction, TransactionEndEventData eventData)
{
DbLock.EndWriteLock(_logger);
DbLock.EndWriteLock(this._logger);
base.TransactionRolledBack(transaction, eventData);
}
public override Task TransactionRolledBackAsync(DbTransaction transaction, TransactionEndEventData eventData, CancellationToken cancellationToken = default)
{
DbLock.EndWriteLock(_logger);
DbLock.EndWriteLock(this._logger);
return base.TransactionRolledBackAsync(transaction, eventData, cancellationToken);
}
@@ -140,12 +147,12 @@ public class PessimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
public CommandLockingInterceptor(ILogger logger)
{
_logger = logger;
this._logger = logger;
}
public override InterceptionResult<int> NonQueryExecuting(DbCommand command, CommandEventData eventData, InterceptionResult<int> result)
{
using (DbLock.EnterWrite(_logger, command))
using (DbLock.EnterWrite(this._logger, command))
{
return InterceptionResult<int>.SuppressWithResult(command.ExecuteNonQuery());
}
@@ -153,7 +160,7 @@ public class PessimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
public override async ValueTask<InterceptionResult<int>> NonQueryExecutingAsync(DbCommand command, CommandEventData eventData, InterceptionResult<int> result, CancellationToken cancellationToken = default)
{
using (DbLock.EnterWrite(_logger, command))
using (DbLock.EnterWrite(this._logger, command))
{
return InterceptionResult<int>.SuppressWithResult(await command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false));
}
@@ -161,7 +168,7 @@ public class PessimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
public override InterceptionResult<object> ScalarExecuting(DbCommand command, CommandEventData eventData, InterceptionResult<object> result)
{
using (DbLock.EnterRead(_logger))
using (DbLock.EnterRead(this._logger))
{
return InterceptionResult<object>.SuppressWithResult(command.ExecuteScalar()!);
}
@@ -169,7 +176,7 @@ public class PessimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
public override async ValueTask<InterceptionResult<object>> ScalarExecutingAsync(DbCommand command, CommandEventData eventData, InterceptionResult<object> result, CancellationToken cancellationToken = default)
{
using (DbLock.EnterRead(_logger))
using (DbLock.EnterRead(this._logger))
{
return InterceptionResult<object>.SuppressWithResult((await command.ExecuteScalarAsync(cancellationToken).ConfigureAwait(false))!);
}
@@ -177,7 +184,7 @@ public class PessimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
public override InterceptionResult<DbDataReader> ReaderExecuting(DbCommand command, CommandEventData eventData, InterceptionResult<DbDataReader> result)
{
using (DbLock.EnterRead(_logger))
using (DbLock.EnterRead(this._logger))
{
return InterceptionResult<DbDataReader>.SuppressWithResult(command.ExecuteReader()!);
}
@@ -185,7 +192,7 @@ public class PessimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
public override async ValueTask<InterceptionResult<DbDataReader>> ReaderExecutingAsync(DbCommand command, CommandEventData eventData, InterceptionResult<DbDataReader> result, CancellationToken cancellationToken = default)
{
using (DbLock.EnterRead(_logger))
using (DbLock.EnterRead(this._logger))
{
return InterceptionResult<DbDataReader>.SuppressWithResult(await command.ExecuteReaderAsync(cancellationToken).ConfigureAwait(false));
}
@@ -194,15 +201,15 @@ public class PessimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
private sealed class DbLock : IDisposable
{
private readonly Action? _action;
private bool _disposed;
private static readonly IDisposable _noLock = new DbLock(null) { _disposed = true };
private static (string Command, Guid Id, DateTimeOffset QueryDate, bool Printed) _blockQuery;
private readonly Action? _action;
private bool _disposed;
public DbLock(Action? action = null)
{
_action = action;
this._action = action;
}
#pragma warning disable IDISP015 // Member should not return created and cached instance
@@ -286,15 +293,15 @@ public class PessimisticLockBehavior : IEntityFrameworkCoreLockingBehavior
public void Dispose()
{
if (_disposed)
if (this._disposed)
{
return;
}
_disposed = true;
if (_action is not null)
this._disposed = true;
if (this._action is not null)
{
_action();
this._action();
}
}
}
@@ -2,8 +2,11 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1602 // Elements should be documented
namespace Jellyfin.Database.Implementations.ModelConfiguration;
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -16,6 +19,7 @@ public class ActivityLogConfiguration : IEntityTypeConfiguration<ActivityLog>
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<ActivityLog> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.HasIndex(entity => entity.DateCreated);
}
}
@@ -4,6 +4,7 @@
namespace Jellyfin.Database.Implementations.ModelConfiguration;
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -16,6 +17,7 @@ public class AncestorIdConfiguration : IEntityTypeConfiguration<AncestorId>
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<AncestorId> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.HasKey(e => new { e.ItemId, e.ParentItemId });
builder.HasIndex(e => e.ParentItemId);
builder.HasOne(e => e.ParentItem).WithMany(e => e.Children).HasForeignKey(f => f.ParentItemId);
@@ -3,21 +3,24 @@
// </copyright>
namespace Jellyfin.Database.Implementations.ModelConfiguration
using Jellyfin.Database.Implementations.Entities.Security;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the ApiKey entity.
/// </summary>
public class ApiKeyConfiguration : IEntityTypeConfiguration<ApiKey>
{
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<ApiKey> builder)
using System;
using Jellyfin.Database.Implementations.Entities.Security;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the ApiKey entity.
/// </summary>
public class ApiKeyConfiguration : IEntityTypeConfiguration<ApiKey>
{
builder
.HasIndex(entity => entity.AccessToken)
.IsUnique();
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<ApiKey> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder
.HasIndex(entity => entity.AccessToken)
.IsUnique();
}
}
}
@@ -4,6 +4,7 @@
namespace Jellyfin.Database.Implementations.ModelConfiguration;
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -16,6 +17,7 @@ public class AttachmentStreamInfoConfiguration : IEntityTypeConfiguration<Attach
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<AttachmentStreamInfo> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.HasKey(e => new { e.ItemId, e.Index });
}
}
@@ -2,6 +2,8 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable SA1515 // Single line comment should be proceeded by blank line
namespace Jellyfin.Database.Implementations.ModelConfiguration;
using System;
@@ -17,6 +19,7 @@ public class BaseItemConfiguration : IEntityTypeConfiguration<BaseItemEntity>
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<BaseItemEntity> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.HasKey(e => e.Id);
// TODO: See rant in entity file.
// builder.HasOne(e => e.Parent).WithMany(e => e.DirectChildren).HasForeignKey(e => e.ParentId);
@@ -4,6 +4,7 @@
namespace Jellyfin.Database.Implementations.ModelConfiguration;
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -16,6 +17,7 @@ public class BaseItemMetadataFieldConfiguration : IEntityTypeConfiguration<BaseI
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<BaseItemMetadataField> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.HasKey(e => new { e.Id, e.ItemId });
builder.HasOne(e => e.Item);
}
@@ -4,6 +4,7 @@
namespace Jellyfin.Database.Implementations.ModelConfiguration;
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -16,6 +17,7 @@ public class BaseItemProviderConfiguration : IEntityTypeConfiguration<BaseItemPr
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<BaseItemProvider> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.HasKey(e => new { e.ItemId, e.ProviderId });
builder.HasOne(e => e.Item);
builder.HasIndex(e => new { e.ProviderId, e.ProviderValue, e.ItemId });
@@ -4,6 +4,7 @@
namespace Jellyfin.Database.Implementations.ModelConfiguration;
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -16,6 +17,7 @@ public class BaseItemTrailerTypeConfiguration : IEntityTypeConfiguration<BaseIte
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<BaseItemTrailerType> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.HasKey(e => new { e.Id, e.ItemId });
builder.HasOne(e => e.Item);
}
@@ -4,6 +4,7 @@
namespace Jellyfin.Database.Implementations.ModelConfiguration;
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -16,6 +17,7 @@ public class ChapterConfiguration : IEntityTypeConfiguration<Chapter>
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<Chapter> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.HasKey(e => new { e.ItemId, e.ChapterIndex });
builder.HasOne(e => e.Item);
}
@@ -3,21 +3,24 @@
// </copyright>
namespace Jellyfin.Database.Implementations.ModelConfiguration
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the CustomItemDisplayPreferences entity.
/// </summary>
public class CustomItemDisplayPreferencesConfiguration : IEntityTypeConfiguration<CustomItemDisplayPreferences>
{
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<CustomItemDisplayPreferences> builder)
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the CustomItemDisplayPreferences entity.
/// </summary>
public class CustomItemDisplayPreferencesConfiguration : IEntityTypeConfiguration<CustomItemDisplayPreferences>
{
builder
.HasIndex(entity => new { entity.UserId, entity.ItemId, entity.Client, entity.Key })
.IsUnique();
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<CustomItemDisplayPreferences> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder
.HasIndex(entity => new { entity.UserId, entity.ItemId, entity.Client, entity.Key })
.IsUnique();
}
}
}
@@ -3,29 +3,32 @@
// </copyright>
namespace Jellyfin.Database.Implementations.ModelConfiguration
using Jellyfin.Database.Implementations.Entities.Security;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the Device entity.
/// </summary>
public class DeviceConfiguration : IEntityTypeConfiguration<Device>
{
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<Device> builder)
using System;
using Jellyfin.Database.Implementations.Entities.Security;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the Device entity.
/// </summary>
public class DeviceConfiguration : IEntityTypeConfiguration<Device>
{
builder
.HasIndex(entity => new { entity.DeviceId, entity.DateLastActivity });
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<Device> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder
.HasIndex(entity => new { entity.DeviceId, entity.DateLastActivity });
builder
.HasIndex(entity => new { entity.AccessToken, entity.DateLastActivity });
builder
.HasIndex(entity => new { entity.AccessToken, entity.DateLastActivity });
builder
.HasIndex(entity => new { entity.UserId, entity.DeviceId });
builder
.HasIndex(entity => new { entity.UserId, entity.DeviceId });
builder
.HasIndex(entity => entity.DeviceId);
builder
.HasIndex(entity => entity.DeviceId);
}
}
}
@@ -3,21 +3,24 @@
// </copyright>
namespace Jellyfin.Database.Implementations.ModelConfiguration
using Jellyfin.Database.Implementations.Entities.Security;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the DeviceOptions entity.
/// </summary>
public class DeviceOptionsConfiguration : IEntityTypeConfiguration<DeviceOptions>
{
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<DeviceOptions> builder)
using System;
using Jellyfin.Database.Implementations.Entities.Security;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the DeviceOptions entity.
/// </summary>
public class DeviceOptionsConfiguration : IEntityTypeConfiguration<DeviceOptions>
{
builder
.HasIndex(entity => entity.DeviceId)
.IsUnique();
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<DeviceOptions> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder
.HasIndex(entity => entity.DeviceId)
.IsUnique();
}
}
}
@@ -3,26 +3,29 @@
// </copyright>
namespace Jellyfin.Database.Implementations.ModelConfiguration
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the DisplayPreferencesConfiguration entity.
/// </summary>
public class DisplayPreferencesConfiguration : IEntityTypeConfiguration<DisplayPreferences>
{
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<DisplayPreferences> builder)
{
builder
.HasMany(d => d.HomeSections)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
builder
.HasIndex(entity => new { entity.UserId, entity.ItemId, entity.Client })
.IsUnique();
/// <summary>
/// FluentAPI configuration for the DisplayPreferencesConfiguration entity.
/// </summary>
public class DisplayPreferencesConfiguration : IEntityTypeConfiguration<DisplayPreferences>
{
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<DisplayPreferences> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder
.HasMany(d => d.HomeSections)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
builder
.HasIndex(entity => new { entity.UserId, entity.ItemId, entity.Client })
.IsUnique();
}
}
}
@@ -4,6 +4,7 @@
namespace Jellyfin.Database.Implementations.ModelConfiguration;
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -16,6 +17,7 @@ public class ItemValuesConfiguration : IEntityTypeConfiguration<ItemValue>
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<ItemValue> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.HasKey(e => e.ItemValueId);
builder.HasIndex(e => new { e.Type, e.CleanValue });
builder.HasIndex(e => new { e.Type, e.Value }).IsUnique();
@@ -4,6 +4,7 @@
namespace Jellyfin.Database.Implementations.ModelConfiguration;
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -16,6 +17,7 @@ public class ItemValuesMapConfiguration : IEntityTypeConfiguration<ItemValueMap>
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<ItemValueMap> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.HasKey(e => new { e.ItemValueId, e.ItemId });
builder.HasOne(e => e.Item);
builder.HasOne(e => e.ItemValue);
@@ -4,6 +4,7 @@
namespace Jellyfin.Database.Implementations.ModelConfiguration;
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -16,6 +17,7 @@ public class KeyframeDataConfiguration : IEntityTypeConfiguration<KeyframeData>
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<KeyframeData> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.HasKey(e => e.ItemId);
builder.HasOne(e => e.Item).WithMany().HasForeignKey(e => e.ItemId);
}
@@ -4,6 +4,7 @@
namespace Jellyfin.Database.Implementations.ModelConfiguration;
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -16,6 +17,7 @@ public class MediaStreamInfoConfiguration : IEntityTypeConfiguration<MediaStream
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<MediaStreamInfo> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.HasKey(e => new { e.ItemId, e.StreamIndex });
builder.HasIndex(e => e.StreamIndex);
builder.HasIndex(e => e.StreamType);
@@ -4,6 +4,7 @@
namespace Jellyfin.Database.Implementations.ModelConfiguration;
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -16,6 +17,7 @@ public class PeopleBaseItemMapConfiguration : IEntityTypeConfiguration<PeopleBas
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<PeopleBaseItemMap> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.HasKey(e => new { e.ItemId, e.PeopleId, e.Role });
builder.HasIndex(e => new { e.ItemId, e.SortOrder });
builder.HasIndex(e => new { e.ItemId, e.ListOrder });
@@ -4,6 +4,7 @@
namespace Jellyfin.Database.Implementations.ModelConfiguration;
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -16,6 +17,7 @@ public class PeopleConfiguration : IEntityTypeConfiguration<People>
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<People> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.HasKey(e => e.Id);
builder.HasIndex(e => e.Name);
builder.HasMany(e => e.BaseItems);
@@ -3,25 +3,28 @@
// </copyright>
namespace Jellyfin.Database.Implementations.ModelConfiguration
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the Permission entity.
/// </summary>
public class PermissionConfiguration : IEntityTypeConfiguration<Permission>
{
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<Permission> builder)
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the Permission entity.
/// </summary>
public class PermissionConfiguration : IEntityTypeConfiguration<Permission>
{
// Used to get a user's permissions or a specific permission for a user.
// Also prevents multiple values being created for a user.
// Filtered over non-null user ids for when other entities (groups, API keys) get permissions
builder
.HasIndex(p => new { p.UserId, p.Kind })
.HasFilter("[UserId] IS NOT NULL")
.IsUnique();
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<Permission> builder)
{
// Used to get a user's permissions or a specific permission for a user.
// Also prevents multiple values being created for a user.
// Filtered over non-null user ids for when other entities (groups, API keys) get permissions
ArgumentNullException.ThrowIfNull(builder);
builder
.HasIndex(p => new { p.UserId, p.Kind })
.HasFilter("[UserId] IS NOT NULL")
.IsUnique();
}
}
}
@@ -3,22 +3,25 @@
// </copyright>
namespace Jellyfin.Database.Implementations.ModelConfiguration
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the Permission entity.
/// </summary>
public class PreferenceConfiguration : IEntityTypeConfiguration<Preference>
{
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<Preference> builder)
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the Permission entity.
/// </summary>
public class PreferenceConfiguration : IEntityTypeConfiguration<Preference>
{
builder
.HasIndex(p => new { p.UserId, p.Kind })
.HasFilter("[UserId] IS NOT NULL")
.IsUnique();
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<Preference> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder
.HasIndex(p => new { p.UserId, p.Kind })
.HasFilter("[UserId] IS NOT NULL")
.IsUnique();
}
}
}
@@ -3,19 +3,22 @@
// </copyright>
namespace Jellyfin.Database.Implementations.ModelConfiguration
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the TrickplayInfo entity.
/// </summary>
public class TrickplayInfoConfiguration : IEntityTypeConfiguration<TrickplayInfo>
{
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<TrickplayInfo> builder)
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the TrickplayInfo entity.
/// </summary>
public class TrickplayInfoConfiguration : IEntityTypeConfiguration<TrickplayInfo>
{
builder.HasKey(info => new { info.ItemId, info.Width });
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<TrickplayInfo> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.HasKey(info => new { info.ItemId, info.Width });
}
}
}
@@ -3,56 +3,59 @@
// </copyright>
namespace Jellyfin.Database.Implementations.ModelConfiguration
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the User entity.
/// </summary>
public class UserConfiguration : IEntityTypeConfiguration<User>
{
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<User> builder)
using System;
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
/// <summary>
/// FluentAPI configuration for the User entity.
/// </summary>
public class UserConfiguration : IEntityTypeConfiguration<User>
{
builder
.Property(user => user.Username);
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<User> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder
.Property(user => user.Username);
builder
.HasOne(u => u.ProfileImage)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
builder
.HasOne(u => u.ProfileImage)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
builder
.HasMany(u => u.Permissions)
.WithOne()
.HasForeignKey(p => p.UserId)
.OnDelete(DeleteBehavior.Cascade);
builder
.HasMany(u => u.Permissions)
.WithOne()
.HasForeignKey(p => p.UserId)
.OnDelete(DeleteBehavior.Cascade);
builder
.HasMany(u => u.Preferences)
.WithOne()
.HasForeignKey(p => p.UserId)
.OnDelete(DeleteBehavior.Cascade);
builder
.HasMany(u => u.Preferences)
.WithOne()
.HasForeignKey(p => p.UserId)
.OnDelete(DeleteBehavior.Cascade);
builder
.HasMany(u => u.AccessSchedules)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
builder
.HasMany(u => u.AccessSchedules)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
builder
.HasMany(u => u.DisplayPreferences)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
builder
.HasMany(u => u.DisplayPreferences)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
builder
.HasMany(u => u.ItemDisplayPreferences)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
builder
.HasMany(u => u.ItemDisplayPreferences)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
builder
.HasIndex(entity => entity.Username)
.IsUnique();
builder
.HasIndex(entity => entity.Username)
.IsUnique();
}
}
}

Some files were not shown because too many files have changed in this diff Show More