LibraryItem.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. /// Initializes a new instance of the <see cref="LibraryItem"/> class.
  23. /// </summary>
  24. protected LibraryItem()
  25. {
  26. }
  27. /// <summary>
  28. /// Gets or sets the id.
  29. /// </summary>
  30. /// <remarks>
  31. /// Identity, Indexed, Required.
  32. /// </remarks>
  33. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  34. public int Id { get; protected set; }
  35. /// <summary>
  36. /// Gets or sets the date this library item was added.
  37. /// </summary>
  38. public DateTime DateAdded { get; protected set; }
  39. /// <inheritdoc />
  40. [ConcurrencyCheck]
  41. public uint RowVersion { get; protected set; }
  42. /// <summary>
  43. /// Gets or sets the library of this item.
  44. /// </summary>
  45. /// <remarks>
  46. /// Required.
  47. /// </remarks>
  48. [Required]
  49. public virtual Library Library { get; set; }
  50. /// <inheritdoc />
  51. public void OnSavingChanges()
  52. {
  53. RowVersion++;
  54. }
  55. }
  56. }