Class SqlHelper
A collection of static methods for manipulating Sql statements.
public class SqlHelper
- Inheritance
-
SqlHelper
- Inherited Members
- Extension Methods
Fields
StatementDefaultSpaces
The spaces to be used when generating Sql statements
public const int StatementDefaultSpaces = 30
Field Value
Methods
DateTimeToStr(DateTime, bool)
Formats Value. Quotes the result if Quoted is true.
public static string DateTimeToStr(DateTime Value, bool Quoted)
Parameters
Returns
DateToStr(DateTime, bool)
Formats Value. Quotes the result if Quoted is true.
public static string DateToStr(DateTime Value, bool Quoted)
Parameters
Returns
ExtractTableName(string)
If the specified CreateTableSqlText is a CREATE TABLE TABLE_NAME (...) sql statement then this method returns the TABLE_NAME, else returns string.Empty
public static string ExtractTableName(string CreateTableSqlText)
Parameters
CreateTableSqlTextstring
Returns
FieldAlias(string, string)
Constructs a field at table string. By default is TableName__FieldName.
public static string FieldAlias(string TableName, string FieldName)
Parameters
Returns
FieldPath(string, string)
Returns a string of the form TableName.FieldName
public static string FieldPath(string TableName, string FieldName)
Parameters
Returns
FloatSQL(double)
Converts the double Value to a float string, valid for S, i.e. ensures that the decimal seperator is the point.
public static string FloatSQL(double Value)
Parameters
Valuedouble
Returns
FloatSql(string)
Converts the string Value to a float string, valid for S, i.e. ensures that the decimal
public static string FloatSql(string Value)
Parameters
Valuestring
Returns
Format(object)
Returns the value of the Value as a string for constructing Sql statements.
In case of a string or DateTime it surrounds the result with single quotes.
public static string Format(object Value)
Parameters
Valueobject
Returns
FormatFieldNameAlias(string, string, int)
Returns a string such as
FieldName as Alias
public static string FormatFieldNameAlias(string FieldName, string Alias, int Spaces)
Parameters
Returns
FormatFieldNameAlias(string, string, string, int)
Returns a string such as
TableNameOrAlias.FieldName as Alias
public static string FormatFieldNameAlias(string TableNameOrAlias, string FieldName, string Alias, int Spaces)
Parameters
Returns
FormatId(object)
Returns the value of the Id as a string for constructing Sql statements.
Id could be either a guid string or a 32-bit integer.
public static string FormatId(object Id)
Parameters
Idobject
Returns
FormatTableNameAlias(string, string)
Returns a string such as
TableName Alias
public static string FormatTableNameAlias(string TableName, string Alias)
Parameters
Returns
GetMainTableName(string)
WARNING: Not reliable
public static string GetMainTableName(string SelectSqlText)
Parameters
SelectSqlTextstring
Returns
IsMasked(string)
Returns true if Value contains any of the mask characters (%, ?, *)
public static bool IsMasked(string Value)
Parameters
Valuestring
Returns
NormalizeMask(string)
Normalizes Value for use in a LIKE clause. It returns a string as
LIKE 'VALUE%'
<p>Value may or may not contain mask characters (%, ?, *)</p>
public static string NormalizeMask(string Value)
Parameters
Valuestring
Returns
NormalizeMask2(string)
Normalizes Value for use in a LIKE clause. It returns a string as
LIKE 'VALUE%'
<p>Value may or may not contain mask characters (%, ?, *)</p>
<p>WARNING: This version adds a % in front of Value, if not there</p>
public static string NormalizeMask2(string Value)
Parameters
Valuestring
Returns
NormalizeMaskForce(string)
Normalizes Value for use in a LIKE clause. It returns a string as
LIKE 'VALUE%'
<p>Value may or may not contain mask characters (%, ?, *)</p>
public static string NormalizeMaskForce(string Value)
Parameters
Valuestring
Returns
TimeToStr(DateTime, bool)
Formats Value. Quotes the result if Quoted is true.
public static string TimeToStr(DateTime Value, bool Quoted)
Parameters
Returns
TransformToFieldList(List<string>)
Transforms a string list into a field list by adding a , and a line break in every string item, except the last one.
public static string TransformToFieldList(List<string> StringList)