Track.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. namespace Jellyfin.Data.Entities
  5. {
  6. public partial class Track : LibraryItem
  7. {
  8. partial void Init();
  9. /// <summary>
  10. /// Default constructor. Protected due to required properties, but present because EF needs it.
  11. /// </summary>
  12. protected Track()
  13. {
  14. // NOTE: This class has one-to-one associations with LibraryRoot, LibraryItem and CollectionItem.
  15. // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other.
  16. Releases = new HashSet<Release>();
  17. TrackMetadata = new HashSet<TrackMetadata>();
  18. Init();
  19. }
  20. /// <summary>
  21. /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving.
  22. /// </summary>
  23. public static Track CreateTrackUnsafe()
  24. {
  25. return new Track();
  26. }
  27. /// <summary>
  28. /// Public constructor with required data
  29. /// </summary>
  30. /// <param name="urlid">This is whats gets displayed in the Urls and API requests. This could also be a string.</param>
  31. /// <param name="_musicalbum0"></param>
  32. public Track(Guid urlid, DateTime dateadded, MusicAlbum _musicalbum0)
  33. {
  34. // NOTE: This class has one-to-one associations with LibraryRoot, LibraryItem and CollectionItem.
  35. // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other.
  36. this.UrlId = urlid;
  37. if (_musicalbum0 == null) throw new ArgumentNullException(nameof(_musicalbum0));
  38. _musicalbum0.Tracks.Add(this);
  39. this.Releases = new HashSet<Release>();
  40. this.TrackMetadata = new HashSet<TrackMetadata>();
  41. Init();
  42. }
  43. /// <summary>
  44. /// Static create function (for use in LINQ queries, etc.)
  45. /// </summary>
  46. /// <param name="urlid">This is whats gets displayed in the Urls and API requests. This could also be a string.</param>
  47. /// <param name="_musicalbum0"></param>
  48. public static Track Create(Guid urlid, DateTime dateadded, MusicAlbum _musicalbum0)
  49. {
  50. return new Track(urlid, dateadded, _musicalbum0);
  51. }
  52. /*************************************************************************
  53. * Properties
  54. *************************************************************************/
  55. /// <summary>
  56. /// Backing field for TrackNumber
  57. /// </summary>
  58. protected int? _TrackNumber;
  59. /// <summary>
  60. /// When provided in a partial class, allows value of TrackNumber to be changed before setting.
  61. /// </summary>
  62. partial void SetTrackNumber(int? oldValue, ref int? newValue);
  63. /// <summary>
  64. /// When provided in a partial class, allows value of TrackNumber to be changed before returning.
  65. /// </summary>
  66. partial void GetTrackNumber(ref int? result);
  67. public int? TrackNumber
  68. {
  69. get
  70. {
  71. int? value = _TrackNumber;
  72. GetTrackNumber(ref value);
  73. return (_TrackNumber = value);
  74. }
  75. set
  76. {
  77. int? oldValue = _TrackNumber;
  78. SetTrackNumber(oldValue, ref value);
  79. if (oldValue != value)
  80. {
  81. _TrackNumber = value;
  82. }
  83. }
  84. }
  85. /*************************************************************************
  86. * Navigation properties
  87. *************************************************************************/
  88. [ForeignKey("Release_Releases_Id")]
  89. public virtual ICollection<Release> Releases { get; protected set; }
  90. [ForeignKey("TrackMetadata_TrackMetadata_Id")]
  91. public virtual ICollection<TrackMetadata> TrackMetadata { get; protected set; }
  92. }
  93. }