PersonRole.cs 2.3 KB

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