PersonRole.cs 6.4 KB

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