| | | 1 | | using System; |
| | | 2 | | using System.ComponentModel.DataAnnotations; |
| | | 3 | | using System.ComponentModel.DataAnnotations.Schema; |
| | | 4 | | using Jellyfin.Database.Implementations.Interfaces; |
| | | 5 | | |
| | | 6 | | namespace Jellyfin.Database.Implementations.Entities.Libraries |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// An entity representing a library item. |
| | | 10 | | /// </summary> |
| | | 11 | | public abstract class LibraryItem : IHasConcurrencyToken |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// Initializes a new instance of the <see cref="LibraryItem"/> class. |
| | | 15 | | /// </summary> |
| | | 16 | | /// <param name="library">The library of this item.</param> |
| | | 17 | | protected LibraryItem(Library library) |
| | | 18 | | { |
| | 0 | 19 | | DateAdded = DateTime.UtcNow; |
| | 0 | 20 | | Library = library; |
| | 0 | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Gets the id. |
| | | 25 | | /// </summary> |
| | | 26 | | /// <remarks> |
| | | 27 | | /// Identity, Indexed, Required. |
| | | 28 | | /// </remarks> |
| | | 29 | | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] |
| | | 30 | | public int Id { get; private set; } |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Gets the date this library item was added. |
| | | 34 | | /// </summary> |
| | | 35 | | public DateTime DateAdded { get; private set; } |
| | | 36 | | |
| | | 37 | | /// <inheritdoc /> |
| | | 38 | | [ConcurrencyCheck] |
| | | 39 | | public uint RowVersion { get; private set; } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Gets or sets the library of this item. |
| | | 43 | | /// </summary> |
| | | 44 | | /// <remarks> |
| | | 45 | | /// Required. |
| | | 46 | | /// </remarks> |
| | | 47 | | public virtual Library Library { get; set; } |
| | | 48 | | |
| | | 49 | | /// <inheritdoc /> |
| | | 50 | | public void OnSavingChanges() |
| | | 51 | | { |
| | 0 | 52 | | RowVersion++; |
| | 0 | 53 | | } |
| | | 54 | | } |
| | | 55 | | } |