Pretty-prints SQL text using various FormatSqlOptions.
public static string FormatSql(
string sqlInputString,
FormatSqlOptions options
)
public:
static String^ FormatSql(
String^ sqlInputString,
FormatSqlOptions^ options
)
sqlInputString
A string containing the SQL text to be formatted.
options
A FormatSqlOptions object that specifies various options that affect the result.
A formatted SQL string.
using Leadtools.Dicom;
using Leadtools.Dicom.Common;
using Leadtools.Dicom.Common.Extensions;
using Leadtools;
using Leadtools.Dicom.Common.Linq.BasicDirectory;
using Leadtools.Dicom.Common.DataTypes;
using Leadtools.Codecs;
public static void FormatSqlExample()
{
// unformatted SQL
string sql =
$"SELECT Patient.PatientID FROM Instance " +
$"INNER " +
$"JOIN Series on Instance.SeriesInstanceUID " +
$"= Series.SeriesInstanceUID INNER JOIN Study on Series.StudyInstanceUID = " +
$"Study.StudyInstanceUID INNER JOIN Patient on Study.PatientID = Patient.PatientID WHERE " +
$"Patient.PatientID Like '%1%' ORDER BY PatientID";
Formatters.FormatSqlOptions options = new Formatters.FormatSqlOptions();
options.NewLineBeforeFromClause = true;
options.NewLineBeforeGroupByClause = true;
options.NewLineBeforeHavingClause = true;
options.NewLineBeforeJoinClause = true;
options.NewLineBeforeOrderByClause = true;
options.NewLineBeforeWhereClause = true;
string formattedSql = Formatters.FormatSql(sql, options);
// This is the result:
//
// SELECT Patient.PatientID
// FROM Instance
// INNER JOIN Series on Instance.SeriesInstanceUID = Series.SeriesInstanceUID
// INNER JOIN Study on Series.StudyInstanceUID = Study.StudyInstanceUID
// INNER JOIN Patient on Study.PatientID = Patient.PatientID
// WHERE Patient.PatientID Like '%1%'
// ORDER BY PatientID
Console.WriteLine(formattedSql);
}
Leadtools.Dicom.Common.Extensions Namespace
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document