Add EntityType enum and support in StoredProcedureBuilder

Introduced the EntityType enum to represent target entities for stored procedure operations, along with XML documentation and mapping comments. Added EntityTypeExtensions with a ToDbString method for consistent DB string conversion. Updated StoredProcedureBuilder to support adding EntityType parameters, improving type safety and maintainability. Minor formatting and using directive adjustments included.
This commit is contained in:
2026-04-16 17:12:19 +02:00
parent 3b4954d387
commit 6374a5c257
2 changed files with 68 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using System.Data;
using System.Text;
@@ -30,6 +31,22 @@ internal sealed class StoredProcedureBuilder(string procedureName, string? retur
return this;
}
public StoredProcedureBuilder Add(string name, EntityType entityType)
{
var entityTypeStr = entityType switch
{
EntityType.Action => "ACTION",
EntityType.Endpoint => "ENDPOINT",
EntityType.EndpointAuth => "ENDPOINT_AUTH",
EntityType.EndpointParams => "ENDPOINT_PARAMS",
EntityType.Profile => "PROFILE",
EntityType.Result => "RESULT",
_ => throw new ArgumentOutOfRangeException(nameof(entityType), $"Not expected entity type value: {entityType}")
};
return Add(name, entityTypeStr);
}
public StoredProcedureBuilder AddOutput(string name, SqlDbType dbType)
{
_execSql.AppendLine($"{_separator}@{name} = @{name} OUTPUT");