Person.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 person.
  10. /// </summary>
  11. public class Person : IHasConcurrencyToken
  12. {
  13. /// <summary>
  14. /// Initializes a new instance of the <see cref="Person"/> class.
  15. /// </summary>
  16. /// <param name="name">The name of the person.</param>
  17. public Person(string name)
  18. {
  19. ArgumentException.ThrowIfNullOrEmpty(name);
  20. Name = name;
  21. DateAdded = DateTime.UtcNow;
  22. DateModified = DateAdded;
  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.
  35. /// </summary>
  36. /// <remarks>
  37. /// Required, Max length = 1024.
  38. /// </remarks>
  39. [MaxLength(1024)]
  40. [StringLength(1024)]
  41. public string Name { get; set; }
  42. /// <summary>
  43. /// Gets or sets the source id.
  44. /// </summary>
  45. /// <remarks>
  46. /// Max length = 255.
  47. /// </remarks>
  48. [MaxLength(256)]
  49. [StringLength(256)]
  50. public string? SourceId { get; set; }
  51. /// <summary>
  52. /// Gets the date added.
  53. /// </summary>
  54. /// <remarks>
  55. /// Required.
  56. /// </remarks>
  57. public DateTime DateAdded { get; private set; }
  58. /// <summary>
  59. /// Gets or sets the date modified.
  60. /// </summary>
  61. /// <remarks>
  62. /// Required.
  63. /// </remarks>
  64. public DateTime DateModified { get; set; }
  65. /// <inheritdoc />
  66. [ConcurrencyCheck]
  67. public uint RowVersion { get; private set; }
  68. /// <summary>
  69. /// Gets a list of metadata sources for this person.
  70. /// </summary>
  71. public virtual ICollection<MetadataProviderId> Sources { get; private set; }
  72. /// <inheritdoc />
  73. public void OnSavingChanges()
  74. {
  75. RowVersion++;
  76. }
  77. }
  78. }