Remove DbModelConfigurationException and related logic
Removed the DbModelConfigurationException class and all its usages from DbModelOptions and EntityOptions. Indexers in these classes no longer throw this exception when configuration is missing. Updated the project file to include the Common\Options\DbModel\ folder.
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
namespace ReC.Application.Common.Exceptions;
|
||||
|
||||
public class DbModelConfigurationException : Exception
|
||||
{
|
||||
public DbModelConfigurationException() { }
|
||||
|
||||
public DbModelConfigurationException(string message) : base(message) { }
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using ReC.Application.Common.Exceptions;
|
||||
|
||||
namespace ReC.Application.Common.Options.DbModel;
|
||||
|
||||
public class DbModelOptions
|
||||
{
|
||||
public Dictionary<string, EntityOptions> Entities { get; set; } = [];
|
||||
|
||||
public EntityOptions this[string entityName]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Entities.TryGetValue(entityName, out var entity))
|
||||
return entity;
|
||||
|
||||
throw new DbModelConfigurationException(
|
||||
$"Entity '{entityName}' is not configured in DbModel options.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using ReC.Application.Common.Exceptions;
|
||||
|
||||
namespace ReC.Application.Common.Options.DbModel;
|
||||
|
||||
public class EntityOptions
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
public string Schema { get; set; } = "dbo";
|
||||
|
||||
public Dictionary<string, string> ColumnMappings { get; set; } = [];
|
||||
|
||||
public string this[string propertyName]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ColumnMappings.TryGetValue(propertyName, out var columnName))
|
||||
return columnName;
|
||||
|
||||
var viewDisplay = Name ?? "unknown";
|
||||
throw new DbModelConfigurationException(
|
||||
$"Column mapping for property '{propertyName}' is not configured for entity '{viewDisplay}'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Common\Behaviors\Action\" />
|
||||
<Folder Include="Common\Options\DbModel\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user