PersonRole.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.ComponentModel.DataAnnotations.Schema;
  5. namespace Jellyfin.Data.Entities
  6. {
  7. public partial class PersonRole
  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 PersonRole()
  14. {
  15. // NOTE: This class has one-to-one associations with PersonRole.
  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. Sources = new HashSet<MetadataProviderId>();
  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 PersonRole CreatePersonRoleUnsafe()
  24. {
  25. return new PersonRole();
  26. }
  27. /// <summary>
  28. /// Public constructor with required data.
  29. /// </summary>
  30. /// <param name="type"></param>
  31. /// <param name="_metadata0"></param>
  32. public PersonRole(Enums.PersonRoleType type, Metadata _metadata0)
  33. {
  34. // NOTE: This class has one-to-one associations with PersonRole.
  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.Type = type;
  37. if (_metadata0 == null)
  38. {
  39. throw new ArgumentNullException(nameof(_metadata0));
  40. }
  41. _metadata0.PersonRoles.Add(this);
  42. this.Sources = new HashSet<MetadataProviderId>();
  43. Init();
  44. }
  45. /// <summary>
  46. /// Static create function (for use in LINQ queries, etc.)
  47. /// </summary>
  48. /// <param name="type"></param>
  49. /// <param name="_metadata0"></param>
  50. public static PersonRole Create(Enums.PersonRoleType type, Metadata _metadata0)
  51. {
  52. return new PersonRole(type, _metadata0);
  53. }
  54. /*************************************************************************
  55. * Properties
  56. *************************************************************************/
  57. /// <summary>
  58. /// Backing field for Id.
  59. /// </summary>
  60. internal int _Id;
  61. /// <summary>
  62. /// When provided in a partial class, allows value of Id to be changed before setting.
  63. /// </summary>
  64. partial void SetId(int oldValue, ref int newValue);
  65. /// <summary>
  66. /// When provided in a partial class, allows value of Id to be changed before returning.
  67. /// </summary>
  68. partial void GetId(ref int result);
  69. /// <summary>
  70. /// Identity, Indexed, Required.
  71. /// </summary>
  72. [Key]
  73. [Required]
  74. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  75. public int Id
  76. {
  77. get
  78. {
  79. int value = _Id;
  80. GetId(ref value);
  81. return _Id = value;
  82. }
  83. protected set
  84. {
  85. int oldValue = _Id;
  86. SetId(oldValue, ref value);
  87. if (oldValue != value)
  88. {
  89. _Id = value;
  90. }
  91. }
  92. }
  93. /// <summary>
  94. /// Backing field for Role.
  95. /// </summary>
  96. protected string _Role;
  97. /// <summary>
  98. /// When provided in a partial class, allows value of Role to be changed before setting.
  99. /// </summary>
  100. partial void SetRole(string oldValue, ref string newValue);
  101. /// <summary>
  102. /// When provided in a partial class, allows value of Role to be changed before returning.
  103. /// </summary>
  104. partial void GetRole(ref string result);
  105. /// <summary>
  106. /// Max length = 1024
  107. /// </summary>
  108. [MaxLength(1024)]
  109. [StringLength(1024)]
  110. public string Role
  111. {
  112. get
  113. {
  114. string value = _Role;
  115. GetRole(ref value);
  116. return _Role = value;
  117. }
  118. set
  119. {
  120. string oldValue = _Role;
  121. SetRole(oldValue, ref value);
  122. if (oldValue != value)
  123. {
  124. _Role = value;
  125. }
  126. }
  127. }
  128. /// <summary>
  129. /// Backing field for Type.
  130. /// </summary>
  131. protected Enums.PersonRoleType _Type;
  132. /// <summary>
  133. /// When provided in a partial class, allows value of Type to be changed before setting.
  134. /// </summary>
  135. partial void SetType(Enums.PersonRoleType oldValue, ref Enums.PersonRoleType newValue);
  136. /// <summary>
  137. /// When provided in a partial class, allows value of Type to be changed before returning.
  138. /// </summary>
  139. partial void GetType(ref Enums.PersonRoleType result);
  140. /// <summary>
  141. /// Required.
  142. /// </summary>
  143. [Required]
  144. public Enums.PersonRoleType Type
  145. {
  146. get
  147. {
  148. Enums.PersonRoleType value = _Type;
  149. GetType(ref value);
  150. return _Type = value;
  151. }
  152. set
  153. {
  154. Enums.PersonRoleType oldValue = _Type;
  155. SetType(oldValue, ref value);
  156. if (oldValue != value)
  157. {
  158. _Type = value;
  159. }
  160. }
  161. }
  162. /// <summary>
  163. /// Required, ConcurrenyToken.
  164. /// </summary>
  165. [ConcurrencyCheck]
  166. [Required]
  167. public uint RowVersion { get; set; }
  168. public void OnSavingChanges()
  169. {
  170. RowVersion++;
  171. }
  172. /*************************************************************************
  173. * Navigation properties
  174. *************************************************************************/
  175. /// <summary>
  176. /// Required.
  177. /// </summary>
  178. [ForeignKey("Person_Id")]
  179. public virtual Person Person { get; set; }
  180. [ForeignKey("Artwork_Artwork_Id")]
  181. public virtual Artwork Artwork { get; set; }
  182. [ForeignKey("MetadataProviderId_Sources_Id")]
  183. public virtual ICollection<MetadataProviderId> Sources { get; protected set; }
  184. }
  185. }