CollectionItem.cs 5.0 KB

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