LibraryItem.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  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 library item.
  9. /// </summary>
  10. public abstract class LibraryItem : IHasConcurrencyToken
  11. {
  12. /// <summary>
  13. /// Initializes a new instance of the <see cref="LibraryItem"/> class.
  14. /// </summary>
  15. /// <param name="library">The library of this item.</param>
  16. protected LibraryItem(Library library)
  17. {
  18. DateAdded = DateTime.UtcNow;
  19. Library = library;
  20. }
  21. /// <summary>
  22. /// Gets the id.
  23. /// </summary>
  24. /// <remarks>
  25. /// Identity, Indexed, Required.
  26. /// </remarks>
  27. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  28. public int Id { get; private set; }
  29. /// <summary>
  30. /// Gets the date this library item was added.
  31. /// </summary>
  32. public DateTime DateAdded { get; private set; }
  33. /// <inheritdoc />
  34. [ConcurrencyCheck]
  35. public uint RowVersion { get; private set; }
  36. /// <summary>
  37. /// Gets or sets the library of this item.
  38. /// </summary>
  39. /// <remarks>
  40. /// Required.
  41. /// </remarks>
  42. public virtual Library Library { get; set; }
  43. /// <inheritdoc />
  44. public void OnSavingChanges()
  45. {
  46. RowVersion++;
  47. }
  48. }
  49. }