Collection.cs 1.6 KB

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