2024-09-08 16:56:14 +00:00
|
|
|
using System;
|
|
|
|
|
using Jellyfin.Data.Entities;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
|
|
|
|
|
|
namespace Jellyfin.Server.Implementations.ModelConfiguration;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// AncestorId configuration.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class AncestorIdConfiguration : IEntityTypeConfiguration<AncestorId>
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public void Configure(EntityTypeBuilder<AncestorId> builder)
|
|
|
|
|
{
|
2024-10-09 23:19:24 +00:00
|
|
|
builder.HasKey(e => new { e.ItemId, e.ParentItemId });
|
|
|
|
|
builder.HasIndex(e => e.ParentItemId);
|
2024-11-12 15:37:01 +00:00
|
|
|
builder.HasOne(e => e.ParentItem).WithMany(e => e.ParentAncestors).HasForeignKey(f => f.ParentItemId);
|
|
|
|
|
builder.HasOne(e => e.Item).WithMany(e => e.Children).HasForeignKey(f => f.ItemId);
|
2024-09-08 16:56:14 +00:00
|
|
|
}
|
|
|
|
|
}
|