CollectionItem.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System.ComponentModel.DataAnnotations;
  2. using System.ComponentModel.DataAnnotations.Schema;
  3. using Jellyfin.Data.Interfaces;
  4. namespace Jellyfin.Data.Entities.Libraries
  5. {
  6. /// <summary>
  7. /// An entity representing a collection item.
  8. /// </summary>
  9. public class CollectionItem : IHasConcurrencyToken
  10. {
  11. /// <summary>
  12. /// Initializes a new instance of the <see cref="CollectionItem"/> class.
  13. /// </summary>
  14. /// <param name="libraryItem">The library item.</param>
  15. public CollectionItem(LibraryItem libraryItem)
  16. {
  17. LibraryItem = libraryItem;
  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; set; }
  27. /// <inheritdoc />
  28. [ConcurrencyCheck]
  29. public uint RowVersion { get; private set; }
  30. /// <summary>
  31. /// Gets or sets the library item.
  32. /// </summary>
  33. /// <remarks>
  34. /// Required.
  35. /// </remarks>
  36. public virtual LibraryItem LibraryItem { get; set; }
  37. /// <summary>
  38. /// Gets or sets the next item in the collection.
  39. /// </summary>
  40. /// <remarks>
  41. /// TODO check if this properly updated Dependent and has the proper principal relationship.
  42. /// </remarks>
  43. public virtual CollectionItem? Next { get; set; }
  44. /// <summary>
  45. /// Gets or sets the previous item in the collection.
  46. /// </summary>
  47. /// <remarks>
  48. /// TODO check if this properly updated Dependent and has the proper principal relationship.
  49. /// </remarks>
  50. public virtual CollectionItem? Previous { get; set; }
  51. /// <inheritdoc />
  52. public void OnSavingChanges()
  53. {
  54. RowVersion++;
  55. }
  56. }
  57. }