CollectionItem.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #pragma warning disable CS1591
  2. using System;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.ComponentModel.DataAnnotations.Schema;
  5. namespace Jellyfin.Data.Entities
  6. {
  7. public partial class CollectionItem
  8. {
  9. partial void Init();
  10. /// <summary>
  11. /// Default constructor. Protected due to required properties, but present because EF needs it.
  12. /// </summary>
  13. protected CollectionItem()
  14. {
  15. // NOTE: This class has one-to-one associations with CollectionItem.
  16. // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other.
  17. Init();
  18. }
  19. /// <summary>
  20. /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving.
  21. /// </summary>
  22. public static CollectionItem CreateCollectionItemUnsafe()
  23. {
  24. return new CollectionItem();
  25. }
  26. /// <summary>
  27. /// Public constructor with required data.
  28. /// </summary>
  29. /// <param name="_collection0"></param>
  30. /// <param name="_collectionitem1"></param>
  31. /// <param name="_collectionitem2"></param>
  32. public CollectionItem(Collection _collection0, CollectionItem _collectionitem1, CollectionItem _collectionitem2)
  33. {
  34. // NOTE: This class has one-to-one associations with 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. if (_collection0 == null)
  37. {
  38. throw new ArgumentNullException(nameof(_collection0));
  39. }
  40. _collection0.CollectionItem.Add(this);
  41. if (_collectionitem1 == null)
  42. {
  43. throw new ArgumentNullException(nameof(_collectionitem1));
  44. }
  45. _collectionitem1.Next = this;
  46. if (_collectionitem2 == null)
  47. {
  48. throw new ArgumentNullException(nameof(_collectionitem2));
  49. }
  50. _collectionitem2.Previous = this;
  51. Init();
  52. }
  53. /// <summary>
  54. /// Static create function (for use in LINQ queries, etc.)
  55. /// </summary>
  56. /// <param name="_collection0"></param>
  57. /// <param name="_collectionitem1"></param>
  58. /// <param name="_collectionitem2"></param>
  59. public static CollectionItem Create(Collection _collection0, CollectionItem _collectionitem1, CollectionItem _collectionitem2)
  60. {
  61. return new CollectionItem(_collection0, _collectionitem1, _collectionitem2);
  62. }
  63. /*************************************************************************
  64. * Properties
  65. *************************************************************************/
  66. /// <summary>
  67. /// Backing field for Id.
  68. /// </summary>
  69. internal int _Id;
  70. /// <summary>
  71. /// When provided in a partial class, allows value of Id to be changed before setting.
  72. /// </summary>
  73. partial void SetId(int oldValue, ref int newValue);
  74. /// <summary>
  75. /// When provided in a partial class, allows value of Id to be changed before returning.
  76. /// </summary>
  77. partial void GetId(ref int result);
  78. /// <summary>
  79. /// Identity, Indexed, Required.
  80. /// </summary>
  81. [Key]
  82. [Required]
  83. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  84. public int Id
  85. {
  86. get
  87. {
  88. int value = _Id;
  89. GetId(ref value);
  90. return _Id = value;
  91. }
  92. protected set
  93. {
  94. int oldValue = _Id;
  95. SetId(oldValue, ref value);
  96. if (oldValue != value)
  97. {
  98. _Id = value;
  99. }
  100. }
  101. }
  102. /// <summary>
  103. /// Required, ConcurrenyToken.
  104. /// </summary>
  105. [ConcurrencyCheck]
  106. [Required]
  107. public uint RowVersion { get; set; }
  108. public void OnSavingChanges()
  109. {
  110. RowVersion++;
  111. }
  112. /*************************************************************************
  113. * Navigation properties
  114. *************************************************************************/
  115. /// <summary>
  116. /// Required.
  117. /// </summary>
  118. [ForeignKey("LibraryItem_Id")]
  119. public virtual LibraryItem LibraryItem { get; set; }
  120. /// <remarks>
  121. /// TODO check if this properly updated dependant and has the proper principal relationship
  122. /// </remarks>
  123. [ForeignKey("CollectionItem_Next_Id")]
  124. public virtual CollectionItem Next { get; set; }
  125. /// <remarks>
  126. /// TODO check if this properly updated dependant and has the proper principal relationship
  127. /// </remarks>
  128. [ForeignKey("CollectionItem_Previous_Id")]
  129. public virtual CollectionItem Previous { get; set; }
  130. }
  131. }