MetadataProvider.cs 4.2 KB

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