Changed the RecActionController Invoke route to remove the {cmd}
parameter, now accepting POST requests at "invoke" only.
Refactored DbModelOptions.EnsureEntity<T> by removing the
entities dictionary conversion logic for virtual and non-virtual
entities.
24 lines
848 B
C#
24 lines
848 B
C#
using ReC.Infrastructure.Exceptions;
|
|
using ReC.Infrastructure.Options.Shared;
|
|
|
|
namespace ReC.Infrastructure.Options;
|
|
|
|
public record DbModelOptions
|
|
{
|
|
public Dictionary<string, EntityOptions> Entities { get; init; } = [];
|
|
|
|
public Dictionary<string, VirtualEntityOptions> VirtualEntities { get; init; } = [];
|
|
|
|
public void EnsureEntity<T>(bool isVirtual)
|
|
{
|
|
var entities = isVirtual
|
|
? VirtualEntities.ToDictionary(kvp => kvp.Key, kvp => kvp.Value as EntityBaseOptions)
|
|
: Entities.ToDictionary(kvp => kvp.Key, kvp => kvp.Value as EntityBaseOptions);
|
|
|
|
if(entities.TryGetValue(nameof(T), out var entityOptions))
|
|
entityOptions.EnsureProperties<T>();
|
|
else
|
|
throw new DbModelConfigurationException($"Entity options for type '{typeof(T).FullName}' not found.");
|
|
}
|
|
}
|