using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Runtime.CompilerServices; namespace Jellyfin.Data.Entities { [Table("Rating")] public partial class Rating { partial void Init(); /// /// Default constructor. Protected due to required properties, but present because EF needs it. /// protected Rating() { Init(); } /// /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving. /// public static Rating CreateRatingUnsafe() { return new Rating(); } /// /// Public constructor with required data /// /// /// public Rating(double value, Metadata _metadata0) { this.Value = value; if (_metadata0 == null) throw new ArgumentNullException(nameof(_metadata0)); _metadata0.Ratings.Add(this); Init(); } /// /// Static create function (for use in LINQ queries, etc.) /// /// /// public static Rating Create(double value, Metadata _metadata0) { return new Rating(value, _metadata0); } /************************************************************************* * Properties *************************************************************************/ /// /// Backing field for Id /// internal int _Id; /// /// When provided in a partial class, allows value of Id to be changed before setting. /// partial void SetId(int oldValue, ref int newValue); /// /// When provided in a partial class, allows value of Id to be changed before returning. /// partial void GetId(ref int result); /// /// Identity, Indexed, Required /// [Key] [Required] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get { int value = _Id; GetId(ref value); return (_Id = value); } protected set { int oldValue = _Id; SetId(oldValue, ref value); if (oldValue != value) { _Id = value; } } } /// /// Backing field for Value /// protected double _Value; /// /// When provided in a partial class, allows value of Value to be changed before setting. /// partial void SetValue(double oldValue, ref double newValue); /// /// When provided in a partial class, allows value of Value to be changed before returning. /// partial void GetValue(ref double result); /// /// Required /// [Required] public double Value { get { double value = _Value; GetValue(ref value); return (_Value = value); } set { double oldValue = _Value; SetValue(oldValue, ref value); if (oldValue != value) { _Value = value; } } } /// /// Backing field for Votes /// protected int? _Votes; /// /// When provided in a partial class, allows value of Votes to be changed before setting. /// partial void SetVotes(int? oldValue, ref int? newValue); /// /// When provided in a partial class, allows value of Votes to be changed before returning. /// partial void GetVotes(ref int? result); public int? Votes { get { int? value = _Votes; GetVotes(ref value); return (_Votes = value); } set { int? oldValue = _Votes; SetVotes(oldValue, ref value); if (oldValue != value) { _Votes = value; } } } /// /// Required, ConcurrenyToken /// [ConcurrencyCheck] [Required] public uint RowVersion { get; set; } public void OnSavingChanges() { RowVersion++; } /************************************************************************* * Navigation properties *************************************************************************/ /// /// If this is NULL it's the internal user rating. /// [ForeignKey("RatingSource_RatingType_Id")] public virtual RatingSource RatingType { get; set; } } }