Library.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. using Jellyfin.Data.Interfaces;
  5. namespace Jellyfin.Data.Entities.Libraries
  6. {
  7. /// <summary>
  8. /// An entity representing a library.
  9. /// </summary>
  10. public class Library : IHasConcurrencyToken
  11. {
  12. /// <summary>
  13. /// Initializes a new instance of the <see cref="Library"/> class.
  14. /// </summary>
  15. /// <param name="name">The name of the library.</param>
  16. public Library(string name)
  17. {
  18. if (string.IsNullOrWhiteSpace(name))
  19. {
  20. throw new ArgumentNullException(nameof(name));
  21. }
  22. Name = name;
  23. }
  24. /// <summary>
  25. /// Initializes a new instance of the <see cref="Library"/> class.
  26. /// </summary>
  27. /// <remarks>
  28. /// Default constructor. Protected due to required properties, but present because EF needs it.
  29. /// </remarks>
  30. protected Library()
  31. {
  32. }
  33. /// <summary>
  34. /// Gets or sets the id.
  35. /// </summary>
  36. /// <remarks>
  37. /// Identity, Indexed, Required.
  38. /// </remarks>
  39. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  40. public int Id { get; protected set; }
  41. /// <summary>
  42. /// Gets or sets the name.
  43. /// </summary>
  44. /// <remarks>
  45. /// Required, Max length = 128.
  46. /// </remarks>
  47. [Required]
  48. [MaxLength(128)]
  49. [StringLength(128)]
  50. public string Name { get; set; }
  51. /// <summary>
  52. /// Gets or sets the root path of the library.
  53. /// </summary>
  54. /// <remarks>
  55. /// Required.
  56. /// </remarks>
  57. [Required]
  58. public string Path { get; set; }
  59. /// <inheritdoc />
  60. [ConcurrencyCheck]
  61. public uint RowVersion { get; set; }
  62. /// <inheritdoc />
  63. public void OnSavingChanges()
  64. {
  65. RowVersion++;
  66. }
  67. }
  68. }