Files
2026-03-25 14:50:13 -05:00

45 lines
2.3 KiB
C#

using System;
using Microsoft.EntityFrameworkCore;
using LCU.Library.Internal.DocumentIngestorModels.Entities;
using Microsoft.EntityFrameworkCore.Query;
namespace LCU.API.Internal.DocumentIngestorLib.Persistence;
public class AppDbContext : DbContext
{
public DbSet<IngestorRunInfo> IngestorRunInfos { get; set; }
public DbSet<DocumentProcessingInfo> DocumentProcessingInfos { get; set; }
public DbSet<ProcessingLog> ProcessingLogs { get; set; }
public DbSet<DocumentTypeArchiveDeleteInfo> DocumentTypeArchiveDeleteInfos { get; set; }
public DbSet<OwnerOverrideInfo> OwnerOverrideInfos { get; set; }
public DbSet<PdfPartitionerRunInfo> PdfPartitionerRunInfos { get; set; }
public DbSet<PdfPartitionerLog> PdfPartitionerLogs { get; set; }
public DbSet<MemberNotificationInfo> MemberNotificationInfos { get; set; }
public DbSet<OsgPreprocessorInfo> OsgPreprocessorInfos { get; set; }
[DbFunction(nameof(JSON_VALUE), IsBuiltIn = true)]
public static string JSON_VALUE(string column, [NotParameterized] string path) => throw new InvalidOperationException();
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<IngestorRunInfo>().ToTable("IngestorRunInfo");
builder.Entity<DocumentProcessingInfo>().ToTable("DocumentProcessingInfo")
.HasMany(x => x.MemberNotificationInfos)
.WithOne()
.HasForeignKey(x => x.DocumentProcessingInfoId)
.IsRequired(false)
.OnDelete(DeleteBehavior.Cascade);
builder.Entity<ProcessingLog>().ToTable("ProcessingLog");
builder.Entity<DocumentTypeArchiveDeleteInfo>().ToTable("DocumentTypeArchiveDeleteInfo");
builder.Entity<DocumentTypeArchiveDeleteInfo>().HasKey(d => d.DocumentTypeName);
builder.Entity<OwnerOverrideInfo>().ToTable("OwnerOverrideInfo");
builder.Entity<PdfPartitionerRunInfo>().ToTable("PdfPartitionerRunInfo");
builder.Entity<PdfPartitionerLog>().ToTable("PdfPartitionerLog");
builder.Entity<MemberNotificationInfo>().ToTable("MemberNotificationInfo");
builder.Entity<OsgPreprocessorInfo>().ToTable("OsgPreprocessorInfo");
}
}