Collection.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections.Generic;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. using Jellyfin.Data.Interfaces;
  5. namespace Jellyfin.Data.Entities.Libraries
  6. {
  7. /// <summary>
  8. /// An entity representing a collection.
  9. /// </summary>
  10. public class Collection : IHasConcurrencyToken
  11. {
  12. /// <summary>
  13. /// Initializes a new instance of the <see cref="Collection"/> class.
  14. /// </summary>
  15. public Collection()
  16. {
  17. Items = new HashSet<CollectionItem>();
  18. }
  19. /// <summary>
  20. /// Gets or sets the id.
  21. /// </summary>
  22. /// <remarks>
  23. /// Identity, Indexed, Required.
  24. /// </remarks>
  25. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  26. public int Id { get; protected set; }
  27. /// <summary>
  28. /// Gets or sets the name.
  29. /// </summary>
  30. /// <remarks>
  31. /// Max length = 1024.
  32. /// </remarks>
  33. [MaxLength(1024)]
  34. [StringLength(1024)]
  35. public string Name { get; set; }
  36. /// <inheritdoc />
  37. [ConcurrencyCheck]
  38. public uint RowVersion { get; set; }
  39. /// <summary>
  40. /// Gets or sets a collection containing this collection's items.
  41. /// </summary>
  42. public virtual ICollection<CollectionItem> Items { get; protected set; }
  43. /// <inheritdoc />
  44. public void OnSavingChanges()
  45. {
  46. RowVersion++;
  47. }
  48. }
  49. }