Person.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #pragma warning disable CA2227
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel.DataAnnotations;
  5. using System.ComponentModel.DataAnnotations.Schema;
  6. using Jellyfin.Data.Interfaces;
  7. namespace Jellyfin.Data.Entities.Libraries
  8. {
  9. /// <summary>
  10. /// An entity representing a person.
  11. /// </summary>
  12. public class Person : IHasConcurrencyToken
  13. {
  14. /// <summary>
  15. /// Initializes a new instance of the <see cref="Person"/> class.
  16. /// </summary>
  17. /// <param name="name">The name of the person.</param>
  18. public Person(string name)
  19. {
  20. if (string.IsNullOrEmpty(name))
  21. {
  22. throw new ArgumentNullException(nameof(name));
  23. }
  24. Name = name;
  25. DateAdded = DateTime.UtcNow;
  26. DateModified = DateAdded;
  27. Sources = new HashSet<MetadataProviderId>();
  28. }
  29. /// <summary>
  30. /// Gets or sets the id.
  31. /// </summary>
  32. /// <remarks>
  33. /// Identity, Indexed, Required.
  34. /// </remarks>
  35. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  36. public int Id { get; protected set; }
  37. /// <summary>
  38. /// Gets or sets the name.
  39. /// </summary>
  40. /// <remarks>
  41. /// Required, Max length = 1024.
  42. /// </remarks>
  43. [MaxLength(1024)]
  44. [StringLength(1024)]
  45. public string Name { get; set; }
  46. /// <summary>
  47. /// Gets or sets the source id.
  48. /// </summary>
  49. /// <remarks>
  50. /// Max length = 255.
  51. /// </remarks>
  52. [MaxLength(256)]
  53. [StringLength(256)]
  54. public string? SourceId { get; set; }
  55. /// <summary>
  56. /// Gets or sets the date added.
  57. /// </summary>
  58. /// <remarks>
  59. /// Required.
  60. /// </remarks>
  61. public DateTime DateAdded { get; protected set; }
  62. /// <summary>
  63. /// Gets or sets the date modified.
  64. /// </summary>
  65. /// <remarks>
  66. /// Required.
  67. /// </remarks>
  68. public DateTime DateModified { get; set; }
  69. /// <inheritdoc />
  70. [ConcurrencyCheck]
  71. public uint RowVersion { get; set; }
  72. /// <summary>
  73. /// Gets or sets a list of metadata sources for this person.
  74. /// </summary>
  75. public virtual ICollection<MetadataProviderId> Sources { get; protected set; }
  76. /// <inheritdoc />
  77. public void OnSavingChanges()
  78. {
  79. RowVersion++;
  80. }
  81. }
  82. }