Preference.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. using Jellyfin.Data.Enums;
  5. using Jellyfin.Data.Interfaces;
  6. namespace Jellyfin.Data.Entities
  7. {
  8. /// <summary>
  9. /// An entity representing a preference attached to a user or group.
  10. /// </summary>
  11. public class Preference : IHasConcurrencyToken
  12. {
  13. /// <summary>
  14. /// Initializes a new instance of the <see cref="Preference"/> class.
  15. /// Public constructor with required data.
  16. /// </summary>
  17. /// <param name="kind">The preference kind.</param>
  18. /// <param name="value">The value.</param>
  19. public Preference(PreferenceKind kind, string value)
  20. {
  21. Kind = kind;
  22. Value = value ?? throw new ArgumentNullException(nameof(value));
  23. }
  24. /// <summary>
  25. /// Gets or sets the id of this preference.
  26. /// </summary>
  27. /// <remarks>
  28. /// Identity, Indexed, Required.
  29. /// </remarks>
  30. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  31. public int Id { get; protected set; }
  32. /// <summary>
  33. /// Gets or sets the type of this preference.
  34. /// </summary>
  35. /// <remarks>
  36. /// Required.
  37. /// </remarks>
  38. public PreferenceKind Kind { get; protected set; }
  39. /// <summary>
  40. /// Gets or sets the value of this preference.
  41. /// </summary>
  42. /// <remarks>
  43. /// Required, Max length = 65535.
  44. /// </remarks>
  45. [MaxLength(65535)]
  46. [StringLength(65535)]
  47. public string Value { get; set; }
  48. /// <inheritdoc/>
  49. [ConcurrencyCheck]
  50. public uint RowVersion { get; set; }
  51. /// <inheritdoc/>
  52. public void OnSavingChanges()
  53. {
  54. RowVersion++;
  55. }
  56. }
  57. }