NETProvider
NETProvider copied to clipboard
Is InsertUsingStoredProcedure, UpdateUsingStoredProcedure, DeleteUsingStoredProcedure in model builder supported?
When i configure model with InsertUsingStoredProcedure and try to save changes, i get an error: SQL error code = -104 Token unknown - line 1, column 1 CALL
Can we fix this issue with this code in FbUpdateSqlGenerator.cs?
public override ResultSetMapping AppendStoredProcedureCall(
StringBuilder commandStringBuilder,
IReadOnlyModificationCommand command,
int commandPosition,
out bool requiresTransaction)
{
var storedProcedure = command.StoreStoredProcedure;
var resultSetMapping = ResultSetMapping.NoResults;
foreach (var resultColumn in storedProcedure.ResultColumns)
{
resultSetMapping = ResultSetMapping.LastInResultSet;
if (resultColumn == command.RowsAffectedColumn)
{
resultSetMapping |= ResultSetMapping.ResultSetWithRowsAffectedOnly;
}
else
{
resultSetMapping = ResultSetMapping.LastInResultSet;
break;
}
}
commandStringBuilder.Append("EXECUTE PROCEDURE ");
SqlGenerationHelper.DelimitIdentifier(commandStringBuilder, storedProcedure.Name);
if (storedProcedure.Parameters.Any())
{
commandStringBuilder.AppendLine();
var first = true;
for (var i = 0; i < command.ColumnModifications.Count; i++)
{
var columnModification = command.ColumnModifications[i];
if (columnModification.Column is not IStoreStoredProcedureParameter parameter)
{
continue;
}
if (parameter.Direction.HasFlag(ParameterDirection.Output))
{
continue;
}
if (first)
{
first = false;
}
else
{
commandStringBuilder.Append(", ");
}
SqlGenerationHelper.GenerateParameterNamePlaceholder(
commandStringBuilder, columnModification.UseOriginalValueParameter
? columnModification.OriginalParameterName!
: columnModification.ParameterName!);
}
}
commandStringBuilder.AppendLine(SqlGenerationHelper.StatementTerminator);
requiresTransaction = true;
return resultSetMapping;
}
Can you create PR?