19 lines
933 B
C#
19 lines
933 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
|
|
namespace SlpModularCms.Modules.Hero.Data;
|
|
|
|
/// <summary>
|
|
/// Where the hero's photos are stored (media library phase 3b). Off (default): the hero's own table <c>HeroImages</c>. On
|
|
/// (<c>Media__Library__HeroPhotosInLibrary=true</c>): the library's <c>MediaAssets</c> table (rows of module <c>hero</c>), with
|
|
/// <c>HeroImages</c> kept up to date as a safety net so the switch can go back. The choice is made when the application starts.
|
|
/// </summary>
|
|
public sealed record HeroStorage(bool PhotosInLibrary);
|
|
|
|
/// <summary>EF builds the model once per key: the two storage modes have different models.</summary>
|
|
public sealed class HeroModelCacheKeyFactory : IModelCacheKeyFactory
|
|
{
|
|
public object Create(DbContext context, bool designTime)
|
|
=> (context.GetType(), context is HeroDbContext { PhotosInLibrary: true }, designTime);
|
|
}
|