using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Jellyfin.Data.Enums; namespace Jellyfin.Data.Entities { /// /// An entity representing a preference attached to a user or group. /// public class Preference : ISavingChanges { /// /// Initializes a new instance of the class. /// Public constructor with required data. /// /// The preference kind. /// The value. public Preference(PreferenceKind kind, string value) { Kind = kind; Value = value ?? throw new ArgumentNullException(nameof(value)); } /// /// Initializes a new instance of the class. /// Default constructor. Protected due to required properties, but present because EF needs it. /// protected Preference() { } /************************************************************************* * Properties *************************************************************************/ /// /// Identity, Indexed, Required /// [Key] [Required] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; protected set; } /// /// Required /// [Required] public PreferenceKind Kind { get; set; } /// /// Required, Max length = 65535 /// [Required] [MaxLength(65535)] [StringLength(65535)] public string Value { get; set; } /// /// Required, ConcurrencyToken. /// [ConcurrencyCheck] [Required] public uint RowVersion { get; set; } /// /// Static create function (for use in LINQ queries, etc.) /// /// The preference kind. /// The value. /// The new instance. public static Preference Create(PreferenceKind kind, string value) { return new Preference(kind, value); } /// public void OnSavingChanges() { RowVersion++; } } }