Collection.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma warning disable CA1711 // Identifiers should not have incorrect suffix
  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 collection.
  10. /// </summary>
  11. public class Collection : IHasConcurrencyToken
  12. {
  13. /// <summary>
  14. /// Initializes a new instance of the <see cref="Collection"/> class.
  15. /// </summary>
  16. public Collection()
  17. {
  18. Items = new HashSet<CollectionItem>();
  19. }
  20. /// <summary>
  21. /// Gets the id.
  22. /// </summary>
  23. /// <remarks>
  24. /// Identity, Indexed, Required.
  25. /// </remarks>
  26. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  27. public int Id { get; private set; }
  28. /// <summary>
  29. /// Gets or sets the name.
  30. /// </summary>
  31. /// <remarks>
  32. /// Max length = 1024.
  33. /// </remarks>
  34. [MaxLength(1024)]
  35. [StringLength(1024)]
  36. public string? Name { get; set; }
  37. /// <inheritdoc />
  38. [ConcurrencyCheck]
  39. public uint RowVersion { get; private set; }
  40. /// <summary>
  41. /// Gets a collection containing this collection's items.
  42. /// </summary>
  43. public virtual ICollection<CollectionItem> Items { get; private set; }
  44. /// <inheritdoc />
  45. public void OnSavingChanges()
  46. {
  47. RowVersion++;
  48. }
  49. }
  50. }