#pragma warning disable CA2227
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Enums;
using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries
{
///
/// An entity representing a person's role in media.
///
public class PersonRole : IHasArtwork, IHasConcurrencyToken
{
///
/// Initializes a new instance of the class.
///
/// The role type.
/// The metadata.
public PersonRole(PersonRoleType type, ItemMetadata itemMetadata)
{
Type = type;
if (itemMetadata == null)
{
throw new ArgumentNullException(nameof(itemMetadata));
}
itemMetadata.PersonRoles.Add(this);
Sources = new HashSet();
}
///
/// Initializes a new instance of the class.
///
///
/// Default constructor. Protected due to required properties, but present because EF needs it.
///
protected PersonRole()
{
}
///
/// Gets or sets the id.
///
///
/// Identity, Indexed, Required.
///
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; protected set; }
///
/// Gets or sets the name of the person's role.
///
///
/// Max length = 1024.
///
[MaxLength(1024)]
[StringLength(1024)]
public string Role { get; set; }
///
/// Gets or sets the person's role type.
///
///
/// Required.
///
public PersonRoleType Type { get; set; }
///
[ConcurrencyCheck]
public uint RowVersion { get; protected set; }
///
/// Gets or sets the person.
///
///
/// Required.
///
[Required]
public virtual Person Person { get; set; }
///
public virtual ICollection Artwork { get; protected set; }
///
/// Gets or sets a collection containing the metadata sources for this person role.
///
public virtual ICollection Sources { get; protected set; }
///
public void OnSavingChanges()
{
RowVersion++;
}
}
}