in src/SqlConverters.cs [158:182]
public virtual async Task<string> BuildItemFromAttributeAsync(SqlAttribute attribute, ConvertType type)
{
using (SqlConnection connection = SqlBindingUtilities.BuildConnection(attribute.ConnectionStringSetting, this._configuration))
// Ideally, we would like to move away from using SqlDataAdapter both here and in the
// SqlAsyncCollector since it does not support asynchronous operations.
using (var adapter = new SqlDataAdapter())
using (SqlCommand command = SqlBindingUtilities.BuildCommand(attribute, connection))
{
adapter.SelectCommand = command;
await connection.OpenAsyncWithSqlErrorHandling(CancellationToken.None);
this._serverProperties = await SqlBindingUtilities.GetServerTelemetryProperties(connection, this._logger, CancellationToken.None);
Dictionary<TelemetryPropertyName, string> props = connection.AsConnectionProps(this._serverProperties);
TelemetryInstance.TrackConvert(type, props);
var dataTable = new DataTable();
adapter.Fill(dataTable);
this._logger.LogInformation($"{dataTable.Rows.Count} row(s) queried from database: {connection.Database} using Command: {command.CommandText}");
// Serialize any DateTime objects in UTC format
var jsonSerializerSettings = new JsonSerializerSettings()
{
DateFormatString = ISO_8061_DATETIME_FORMAT
};
return Utils.JsonSerializeObject(dataTable, jsonSerializerSettings);
}
}