Genre.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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)) throw new ArgumentNullException(nameof(name));
  31. this.Name = name;
  32. if (_metadata0 == null) throw new ArgumentNullException(nameof(_metadata0));
  33. _metadata0.Genres.Add(this);
  34. Init();
  35. }
  36. /// <summary>
  37. /// Static create function (for use in LINQ queries, etc.)
  38. /// </summary>
  39. /// <param name="name"></param>
  40. /// <param name="_metadata0"></param>
  41. public static Genre Create(string name, Metadata _metadata0)
  42. {
  43. return new Genre(name, _metadata0);
  44. }
  45. /*************************************************************************
  46. * Properties
  47. *************************************************************************/
  48. /// <summary>
  49. /// Backing field for Id.
  50. /// </summary>
  51. internal int _Id;
  52. /// <summary>
  53. /// When provided in a partial class, allows value of Id to be changed before setting.
  54. /// </summary>
  55. partial void SetId(int oldValue, ref int newValue);
  56. /// <summary>
  57. /// When provided in a partial class, allows value of Id to be changed before returning.
  58. /// </summary>
  59. partial void GetId(ref int result);
  60. /// <summary>
  61. /// Identity, Indexed, Required.
  62. /// </summary>
  63. [Key]
  64. [Required]
  65. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  66. public int Id
  67. {
  68. get
  69. {
  70. int value = _Id;
  71. GetId(ref value);
  72. return (_Id = value);
  73. }
  74. protected set
  75. {
  76. int oldValue = _Id;
  77. SetId(oldValue, ref value);
  78. if (oldValue != value)
  79. {
  80. _Id = value;
  81. }
  82. }
  83. }
  84. /// <summary>
  85. /// Backing field for Name.
  86. /// </summary>
  87. internal string _Name;
  88. /// <summary>
  89. /// When provided in a partial class, allows value of Name to be changed before setting.
  90. /// </summary>
  91. partial void SetName(string oldValue, ref string newValue);
  92. /// <summary>
  93. /// When provided in a partial class, allows value of Name to be changed before returning.
  94. /// </summary>
  95. partial void GetName(ref string result);
  96. /// <summary>
  97. /// Indexed, Required, Max length = 255
  98. /// </summary>
  99. [Required]
  100. [MaxLength(255)]
  101. [StringLength(255)]
  102. public string Name
  103. {
  104. get
  105. {
  106. string value = _Name;
  107. GetName(ref value);
  108. return (_Name = value);
  109. }
  110. set
  111. {
  112. string oldValue = _Name;
  113. SetName(oldValue, ref value);
  114. if (oldValue != value)
  115. {
  116. _Name = value;
  117. }
  118. }
  119. }
  120. /// <summary>
  121. /// Required, ConcurrenyToken.
  122. /// </summary>
  123. [ConcurrencyCheck]
  124. [Required]
  125. public uint RowVersion { get; set; }
  126. public void OnSavingChanges()
  127. {
  128. RowVersion++;
  129. }
  130. /*************************************************************************
  131. * Navigation properties
  132. *************************************************************************/
  133. }
  134. }