PersonRole.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #pragma warning disable CA2227
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.ComponentModel.DataAnnotations.Schema;
  5. using Jellyfin.Data.Enums;
  6. using Jellyfin.Data.Interfaces;
  7. namespace Jellyfin.Data.Entities.Libraries
  8. {
  9. /// <summary>
  10. /// An entity representing a person's role in media.
  11. /// </summary>
  12. public class PersonRole : IHasArtwork, IHasConcurrencyToken
  13. {
  14. /// <summary>
  15. /// Initializes a new instance of the <see cref="PersonRole"/> class.
  16. /// </summary>
  17. /// <param name="type">The role type.</param>
  18. /// <param name="person">The person.</param>
  19. public PersonRole(PersonRoleType type, Person person)
  20. {
  21. Type = type;
  22. Person = person;
  23. Artwork = new HashSet<Artwork>();
  24. Sources = new HashSet<MetadataProviderId>();
  25. }
  26. /// <summary>
  27. /// Gets or sets the id.
  28. /// </summary>
  29. /// <remarks>
  30. /// Identity, Indexed, Required.
  31. /// </remarks>
  32. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  33. public int Id { get; protected set; }
  34. /// <summary>
  35. /// Gets or sets the name of the person's role.
  36. /// </summary>
  37. /// <remarks>
  38. /// Max length = 1024.
  39. /// </remarks>
  40. [MaxLength(1024)]
  41. [StringLength(1024)]
  42. public string? Role { get; set; }
  43. /// <summary>
  44. /// Gets or sets the person's role type.
  45. /// </summary>
  46. /// <remarks>
  47. /// Required.
  48. /// </remarks>
  49. public PersonRoleType Type { get; set; }
  50. /// <inheritdoc />
  51. [ConcurrencyCheck]
  52. public uint RowVersion { get; protected set; }
  53. /// <summary>
  54. /// Gets or sets the person.
  55. /// </summary>
  56. /// <remarks>
  57. /// Required.
  58. /// </remarks>
  59. public virtual Person Person { get; set; }
  60. /// <inheritdoc />
  61. public virtual ICollection<Artwork> Artwork { get; protected set; }
  62. /// <summary>
  63. /// Gets or sets a collection containing the metadata sources for this person role.
  64. /// </summary>
  65. public virtual ICollection<MetadataProviderId> Sources { get; protected set; }
  66. /// <inheritdoc />
  67. public void OnSavingChanges()
  68. {
  69. RowVersion++;
  70. }
  71. }
  72. }