Refactor EnsureEntity<T> for clarity and consistency

Renamed local variable from 'cluster' to 'entities' in EnsureEntity<T> and unified logic for selecting entity options. Improved readability by consistently using entities.TryGetValue and clearer variable naming.
This commit is contained in:
2025-12-10 15:00:44 +01:00
parent 07fca00344
commit c8f3b29329

View File

@@ -12,11 +12,11 @@ public record DbModelOptions
public void EnsureEntity<T>(bool isVirtual) public void EnsureEntity<T>(bool isVirtual)
{ {
var cluster = isVirtual var entities = isVirtual
? VirtualEntities.ToDictionary(kvp => kvp.Key, kvp => kvp.Value as EntityBaseOptions) ? VirtualEntities.ToDictionary(kvp => kvp.Key, kvp => kvp.Value as EntityBaseOptions)
: Entities.ToDictionary(kvp => kvp.Key, kvp => kvp.Value as EntityBaseOptions); : Entities.ToDictionary(kvp => kvp.Key, kvp => kvp.Value as EntityBaseOptions);
if(cluster.TryGetValue(nameof(T), out var entityOptions)) if(entities.TryGetValue(nameof(T), out var entityOptions))
entityOptions.EnsureProperties<T>(); entityOptions.EnsureProperties<T>();
else else
throw new DbModelConfigurationException($"Entity options for type '{typeof(T).FullName}' not found."); throw new DbModelConfigurationException($"Entity options for type '{typeof(T).FullName}' not found.");