using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries
{
///
/// An entity representing a unique identifier for a metadata provider.
///
public class MetadataProviderId : IHasConcurrencyToken
{
///
/// Initializes a new instance of the class.
///
/// The provider id.
/// The metadata provider.
public MetadataProviderId(string providerId, MetadataProvider metadataProvider)
{
if (string.IsNullOrEmpty(providerId))
{
throw new ArgumentNullException(nameof(providerId));
}
ProviderId = providerId;
MetadataProvider = metadataProvider;
}
///
/// Gets or sets the id.
///
///
/// Identity, Indexed, Required.
///
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; protected set; }
///
/// Gets or sets the provider id.
///
///
/// Required, Max length = 255.
///
[MaxLength(255)]
[StringLength(255)]
public string ProviderId { get; set; }
///
[ConcurrencyCheck]
public uint RowVersion { get; set; }
///
/// Gets or sets the metadata provider.
///
///
/// Required.
///
public virtual MetadataProvider MetadataProvider { get; set; }
///
public void OnSavingChanges()
{
RowVersion++;
}
}
}