Release.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.ComponentModel.DataAnnotations.Schema;
  5. using Jellyfin.Data.Interfaces;
  6. namespace Jellyfin.Data.Entities.Libraries
  7. {
  8. /// <summary>
  9. /// An entity representing a release for a library item, eg. Director's cut vs. standard.
  10. /// </summary>
  11. public class Release : IHasConcurrencyToken
  12. {
  13. /// <summary>
  14. /// Initializes a new instance of the <see cref="Release"/> class.
  15. /// </summary>
  16. /// <param name="name">The name of this release.</param>
  17. public Release(string name)
  18. {
  19. ArgumentException.ThrowIfNullOrEmpty(name);
  20. Name = name;
  21. MediaFiles = new HashSet<MediaFile>();
  22. Chapters = new HashSet<Chapter>();
  23. }
  24. /// <summary>
  25. /// Gets the id.
  26. /// </summary>
  27. /// <remarks>
  28. /// Identity, Indexed, Required.
  29. /// </remarks>
  30. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  31. public int Id { get; private set; }
  32. /// <summary>
  33. /// Gets or sets the name.
  34. /// </summary>
  35. /// <remarks>
  36. /// Required, Max length = 1024.
  37. /// </remarks>
  38. [MaxLength(1024)]
  39. [StringLength(1024)]
  40. public string Name { get; set; }
  41. /// <inheritdoc />
  42. [ConcurrencyCheck]
  43. public uint RowVersion { get; private set; }
  44. /// <summary>
  45. /// Gets a collection containing the media files for this release.
  46. /// </summary>
  47. public virtual ICollection<MediaFile> MediaFiles { get; private set; }
  48. /// <summary>
  49. /// Gets a collection containing the chapters for this release.
  50. /// </summary>
  51. public virtual ICollection<Chapter> Chapters { get; private set; }
  52. /// <inheritdoc />
  53. public void OnSavingChanges()
  54. {
  55. RowVersion++;
  56. }
  57. }
  58. }