private TItem Get<TItem>(
/*WYSE*/IExecutable executable,
Func<DbDataReader, TItem> getResult,
TraceTree parentTraceTree)
{
var traceTree = parentTraceTree.AddChild();
traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
using MySqlConnection connection = _connectionFactory.Create();
connection.Open();
// Aliases and parameter names can be given custom values.
// If omitted, unique identifer values are supplied
// In the case of this Demo, these generated values are overwritten,
// based on the current render settings, with more legible values.
// WYSE supports several kinds of Resetting/renaming.
ResetIdentifiers(executable);
using MySqlCommand command = connection.CreateCommand()
// A WYSE Render context determines certain (overridable) render settings.
// Here the context is MySql. More SQL flavors are supported.
// A WYSE render builder is used for stringifying
// the strongly typed SQL statements.
/*WYSE*/.For(executable, _renderContextFactory.Create(), _createRenderBuilder);
try
{
using DbDataReader reader = command.ExecuteReader();
var result = getResult(reader);
traceTree.RecordDbCommandExecutionSuccess(
command.CommandText,
command.Parameters.ToDictionary(),
result);
return result;
}
catch (Exception exception)
{
traceTree.RecordDbCommandExecutionFailure(
command.CommandText,
command.Parameters.ToDictionary(),
exception);
return default;
}
}