20 lines
908 B
C#
20 lines
908 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using Prefab.Handler;
|
|
|
|
namespace Prefab.Catalog.Api.Data;
|
|
|
|
public class AppDbReadOnly(DbContextOptions<AppDbReadOnly> options, IHandlerContextAccessor accessor) : AppDb(options, accessor), Prefab.Data.IPrefabDbReadOnly,
|
|
Prefab.Catalog.Data.IModuleDbReadOnly
|
|
{
|
|
protected override void PrefabOnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
base.PrefabOnConfiguring(optionsBuilder);
|
|
optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
|
|
}
|
|
|
|
public override int SaveChanges()
|
|
=> throw new InvalidOperationException("This database context is read-only. Saving changes is not allowed.");
|
|
|
|
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
|
=> throw new InvalidOperationException("This database context is read-only. Saving changes is not allowed.");
|
|
} |