Genre.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. namespace Jellyfin.Data.Entities
  5. {
  6. public partial class Genre
  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 Genre()
  13. {
  14. Init();
  15. }
  16. /// <summary>
  17. /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving.
  18. /// </summary>
  19. public static Genre CreateGenreUnsafe()
  20. {
  21. return new Genre();
  22. }
  23. /// <summary>
  24. /// Public constructor with required data.
  25. /// </summary>
  26. /// <param name="name"></param>
  27. /// <param name="_metadata0"></param>
  28. public Genre(string name, Metadata _metadata0)
  29. {
  30. if (string.IsNullOrEmpty(name))
  31. {
  32. throw new ArgumentNullException(nameof(name));
  33. }
  34. this.Name = name;
  35. if (_metadata0 == null)
  36. {
  37. throw new ArgumentNullException(nameof(_metadata0));
  38. }
  39. _metadata0.Genres.Add(this);
  40. Init();
  41. }
  42. /// <summary>
  43. /// Static create function (for use in LINQ queries, etc.)
  44. /// </summary>
  45. /// <param name="name"></param>
  46. /// <param name="_metadata0"></param>
  47. public static Genre Create(string name, Metadata _metadata0)
  48. {
  49. return new Genre(name, _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 Name.
  92. /// </summary>
  93. internal string _Name;
  94. /// <summary>
  95. /// When provided in a partial class, allows value of Name to be changed before setting.
  96. /// </summary>
  97. partial void SetName(string oldValue, ref string newValue);
  98. /// <summary>
  99. /// When provided in a partial class, allows value of Name to be changed before returning.
  100. /// </summary>
  101. partial void GetName(ref string result);
  102. /// <summary>
  103. /// Indexed, Required, Max length = 255
  104. /// </summary>
  105. [Required]
  106. [MaxLength(255)]
  107. [StringLength(255)]
  108. public string Name
  109. {
  110. get
  111. {
  112. string value = _Name;
  113. GetName(ref value);
  114. return _Name = value;
  115. }
  116. set
  117. {
  118. string oldValue = _Name;
  119. SetName(oldValue, ref value);
  120. if (oldValue != value)
  121. {
  122. _Name = value;
  123. }
  124. }
  125. }
  126. /// <summary>
  127. /// Required, ConcurrenyToken.
  128. /// </summary>
  129. [ConcurrencyCheck]
  130. [Required]
  131. public uint RowVersion { get; set; }
  132. public void OnSavingChanges()
  133. {
  134. RowVersion++;
  135. }
  136. /*************************************************************************
  137. * Navigation properties
  138. *************************************************************************/
  139. }
  140. }