PersonRole.cs 6.5 KB

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