Show / Hide Table of Contents

Class PostgreSqlDialect

This class contains the common SQL-syntax for PostgreSQL.

Inheritance
object
Dialect
PostgreSqlDialect
Inherited Members
Dialect._tables
Dialect._tablesInJoin
Dialect._returnDBFields
Dialect._dbSchemaTable
Dialect._soSchemaTable
Dialect._returnArguments
Dialect._usedAliases
Dialect._filterCallbacks
Dialect._cmd
Dialect._stringFieldsInOrderByWithDistinct
Dialect.CheckForDuplicateRow(IDataReader)
Dialect.CheckForDistinct(PrivateSelect)
Dialect.ShouldRowBeSkipped(IDataReader)
Dialect.IsTableReferencedInSelect(SoTable)
Dialect.GetUpdatedSchemaTable(DataTable)
Dialect.GenerateCaseInsensitivity(FieldInfo, Parameter, string)
Dialect.GetOriginAsComment(SqlCommand)
Dialect.HandleDateAndTimeWrapping(string, FieldDataType)
Dialect.GetFieldDbDataType(int)
Dialect.GetIndexOfField(Argument)
Dialect.GetFieldInfoFromIndex(int)
Dialect.CheckForAlias()
Dialect.InvokeToSql(params object[])
Dialect.IsAnyArgumentString(params Argument[])
Dialect.ToSqlUpperIfNeeded(Argument)
Dialect.ToSqlFrom(SqlType)
Dialect.ToSqlField(FieldInfoCollection)
Dialect.ToSqlField(ArgumentCollection)
Dialect.ToSqlField(ReturnFieldsCollection)
Dialect.ToSql(Argument)
Dialect.GetOrderbyCollationHint()
Dialect.ToSql(OrderBy)
Dialect.ToSql(GroupBy)
Dialect.ToSql(Count)
Dialect.ToSql(CountAll)
Dialect.ToSql(IsNull)
Dialect.ToSql(IsNotNull)
Dialect.EncodedArraySearch(Argument, Argument[], Dialect.EncodedArraySearchType, Dialect.FulltextEncodedSearch)
Dialect.ToSql(In)
Dialect.ToSql(HasAny)
Dialect.ToSql(HasAll)
Dialect.ToSql(MissingAny)
Dialect.ToSql(MissingAll)
Dialect.ToSql(NotIn)
Dialect.ToSql(Between)
Dialect.ToSql(NotBetween)
Dialect.ToSql(Parameter)
Dialect.ToSql(LessThan)
Dialect.ToSql(GreaterThan)
Dialect.ToSql(LessThanOrEqual)
Dialect.ToSql(GreaterThanOrEqual)
Dialect.ToSql(HasFlag)
Dialect.ToSql(HasNoFlag)
Dialect.ToSql(And)
Dialect.ToSql(Or)
Dialect.ParseMathematicalArguments(MathematicalExpression, string)
Dialect.ToSql(Greatest)
Dialect.ToSql(Subtract)
Dialect.ToSql(Multiply)
Dialect.ToSql(Divide)
Dialect.ToSql(LeftOuterJoin)
Dialect.ToSql(RightOuterJoin)
Dialect.ToSql(InnerJoin)
Dialect.ParseJoinClause(JoinRestriction)
Dialect.ToSql(Distinct)
Dialect.ToSql(Alias)
Dialect.ToSql(FieldTypeConvert)
Dialect.ToSql(JsonValue)
Dialect.ToSql(FieldDataType)
Dialect.ToSql(Soundex)
Dialect.ToSql(Year)
Dialect.ToSql(Month)
Dialect.ToSql(Day)
Dialect.ToSql(Hour)
Dialect.ToSql(Minute)
Dialect.ToSql(Second)
Dialect.ToSql(Sum)
Dialect.ToSql(Max)
Dialect.ToSql(Min)
Dialect.TableOptions(TableInfo, SqlType)
Dialect.ConvertToDbType(object, FieldDataType)
Dialect.ConvertFromDbType(object, FieldDataType)
Dialect.ConvertToDbString(string)
Dialect.TimeTUtc2DateTime(int)
Dialect.TimeTLocal2DateTime(int)
Dialect.DateTime2TimeTUtc(DateTime)
Dialect.DateTime2TimeTLocal(DateTime)
Dialect.SelectSql(PrivateSelect)
Dialect.ComposeSelect(string, string, string, string, StringBuilder, PrivateSelect)
Dialect.InsertSql(PrivateSave)
Dialect.UpdateSql(PrivateSave)
Dialect.DeleteSql(PrivateSave)
Dialect.UnionSql(TableExpression)
Dialect.PreParseUnion(TableExpression)
Dialect.DifferenceSql(TableExpression)
Dialect.GenerateSql(SqlCommand)
Dialect.FieldIsClob(Argument)
Dialect.FieldIsString(Argument)
Dialect.DataReaderGetName(SoDataReader, IDataReader, int)
Dialect.DataReaderGetDataTypeName(SoDataReader, IDataReader, int)
Dialect.DataReaderGetFieldType(SoDataReader, IDataReader, int)
Dialect.DataReaderGetValue(SoDataReader, IDataReader, int)
Dialect.DataReaderGetOrdinal(SoDataReader, IDataReader, string)
Dialect.DataReaderGetItem(SoDataReader, IDataReader, int)
Dialect.DataReaderGetNullValue(SoDataReader, int)
Dialect.DataReaderGetBoolean(SoDataReader, IDataReader, int)
Dialect.DataReaderGetByte(SoDataReader, IDataReader, int)
Dialect.DataReaderGetBytes(SoDataReader, IDataReader, int, long, byte[], int, int)
Dialect.DataReaderGetChar(SoDataReader, IDataReader, int)
Dialect.DataReaderGetChars(SoDataReader, IDataReader, int, long, char[], int, int)
Dialect.DataReaderGetGuid(SoDataReader, IDataReader, int)
Dialect.DataReaderGetInt16(SoDataReader, IDataReader, int)
Dialect.DataReaderGetInt32(SoDataReader, IDataReader, int)
Dialect.DataReaderGetInt32Array(SoDataReader, IDataReader, int)
Dialect.DataReaderGetInt64(SoDataReader, IDataReader, int)
Dialect.DataReaderGetFloat(SoDataReader, IDataReader, int)
Dialect.DataReaderGetDouble(SoDataReader, IDataReader, int)
Dialect.DataReaderGetString(SoDataReader, IDataReader, int)
Dialect.DataReaderGetDecimal(SoDataReader, IDataReader, int)
Dialect.DataReaderGetDateTime(SoDataReader, IDataReader, int)
Dialect.DataReaderGetData(SoDataReader, IDataReader, int)
Dialect.DataReaderIsDBNullAsync(SoDataReader, DbDataReader, int, CancellationToken)
Dialect.IntToSingleWord(int)
Dialect.IntArrayToWordString(params int[])
Dialect.IntFromSingleWord(string)
Dialect.IntArrayFromWordString(string)
Dialect.GetIsolationLevel(IsolationLevel)
Dialect.GetDefaultTransaction(SoConnection, SqlCommand)
Dialect.DataReaderIsDBNull(SoDataReader, DbDataReader, int)
Dialect.CaseSensitiveDatabase
Dialect.BlockUpperInOrderBy
Dialect.MaxInSize
Dialect.Tables
Dialect.ReturnDBFields
Dialect.HasAliasOnSelect
Dialect.CurrentSqlType
Dialect.CurrentOuterSqlType
Dialect.ReturnFieldsIndexer
Dialect.VarcharType
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice.Data.Dialect
Assembly: SoDataBase.BusinessLogic.dll
Syntax
public class PostgreSqlDialect : Dialect

Properties

DefaultConnectionString

Get default connection string

Declaration
public override string DefaultConnectionString { get; }
Property Value
Type Description
string
Overrides
Dialect.DefaultConnectionString

HasAliasOnDelete

Used to check if alias is used with fields and tables in the SQL DELETE-command.

Declaration
protected override bool HasAliasOnDelete { get; }
Property Value
Type Description
bool
Overrides
Dialect.HasAliasOnDelete
Remarks

Default value is true.

Examples

This method can be overridden in the following manner:

protected override bool HasaliasOnDelete { get { return false; } }

HasAliasOnInsert

Used to check if alias is used with fields and tables in the SQL INSERT-command.

Declaration
protected override bool HasAliasOnInsert { get; }
Property Value
Type Description
bool
Overrides
Dialect.HasAliasOnInsert
Remarks

Default value is true

For example see HasAliasOnDelete

HasAliasOnUpdate

Used to check if alias is used with fields and tables in the SQL UPDATE-command.

Declaration
protected override bool HasAliasOnUpdate { get; }
Property Value
Type Description
bool
Overrides
Dialect.HasAliasOnUpdate
Remarks

Default value is true

For example see HasAliasOnDelete

Methods

ConvertToDbParameterType(object, FieldDataType)

This class contains the common SQL-syntax for PostgreSQL.

Declaration
public override object ConvertToDbParameterType(object value, FieldDataType dataType)
Parameters
Type Name Description
object value
FieldDataType dataType
Returns
Type Description
object
Overrides
Dialect.ConvertToDbParameterType(object, FieldDataType)

DateToVarchar(string)

Subclass override: How to convert a datetime to a varchar (or whatever it's called), in the database, taking only the DATE part

Declaration
protected override string DateToVarchar(string innerValue)
Parameters
Type Name Description
string innerValue

The actual reference to the datetime to work on; this is an opaque parameter that the method should NOT attempt to understand, just assume it will be a valid datetime value or parameter at query-execution time

Returns
Type Description
string
Overrides
Dialect.DateToVarchar(string)

LockReader<T>(SoDataReader, Func<T>)

The PostgreSQL data reader is not thread safe so we need to lock every call; typically to the innerReader. This is helper method to do that.

Declaration
public override T LockReader<T>(SoDataReader soReader, Func<T> innerLogic)
Parameters
Type Name Description
SoDataReader soReader
Func<T> innerLogic
Returns
Type Description
T
Type Parameters
Name Description
T
Overrides
Dialect.LockReader<T>(SoDataReader, Func<T>)

TimeToVarchar(string)

Subclass override: How to convert a datetime to a varchar (or whatever it's called), in the database, taking only the TIME part

Declaration
protected override string TimeToVarchar(string innerValue)
Parameters
Type Name Description
string innerValue

The actual reference to the datetime to work on; this is an opaque parameter that the method should NOT attempt to understand, just assume it will be a valid datetime value or parameter at query-execution time

Returns
Type Description
string
Overrides
Dialect.TimeToVarchar(string)

ToSql(Add)

The Add-operator will return the correct field and its correct sqlOperator.

T0.associate_id = T0.associate_id + 1;
Declaration
protected override string ToSql(Add arg)
Parameters
Type Name Description
Add arg
Returns
Type Description
string
Overrides
Dialect.ToSql(Add)

ToSql(DateAdd)

This class contains the common SQL-syntax for PostgreSQL.

Declaration
protected override string ToSql(DateAdd arg)
Parameters
Type Name Description
DateAdd arg
Returns
Type Description
string
Overrides
Dialect.ToSql(DateAdd)

ToSql(Equal)

You will never use the == (equal) operator on anything else then fields and numeric parameters ( expressions... and/ or other fields ). So we just return the arg.Left == arg.Right. If the right hand side isn't a numeric value, the return value is null.

Declaration
protected override string ToSql(Equal arg)
Parameters
Type Name Description
Equal arg
Returns
Type Description
string
Overrides
Dialect.ToSql(Equal)

ToSql(FieldInfo)

Will return the Field's name together with the generated table-alias.

T1."contact"
Declaration
protected override string ToSql(FieldInfo arg)
Parameters
Type Name Description
FieldInfo arg
Returns
Type Description
string
Overrides
Dialect.ToSql(FieldInfo)

ToSql(Like)

The Like (LIKE) operator is used when you want the left string-value to be somewhat similar to the right string-value,

WHERE contact.name LIKE 'Super%'
We add the wildcard-operator (%) to the end. A LIKE clause isn't very interesting without it. If the programmer don't want this, parse and remove it when the function returns the correct sql-string.

Declaration
protected override string ToSql(Like arg)
Parameters
Type Name Description
Like arg
Returns
Type Description
string
Overrides
Dialect.ToSql(Like)

ToSql(Lower)

ToSql( Lower arg ) will return the given argument enclosed by the SQL LOWER function.

Declaration
protected override string ToSql(Lower arg)
Parameters
Type Name Description
Lower arg

The argument to wrap LOWER around.

Returns
Type Description
string

The parsed LOWER-string

Overrides
Dialect.ToSql(Lower)

ToSql(NotLike)

The Not Like (NOT LIKE) operator is used when you do not want the left string-value to be somewhat similar to the right string-value,

WHERE contact.name NOT LIKE 'Super%'
We add the wildcard-operator (%) to the end. A NOT LIKE clause isn't very interesting without it. If the programmer don't want this, parse and remove it when the function returns the correct sql-string.

Declaration
protected override string ToSql(NotLike arg)
Parameters
Type Name Description
NotLike arg
Returns
Type Description
string
Overrides
Dialect.ToSql(NotLike)

ToSql(TableInfo)

Will return the Table's name including table prefix.

Declaration
protected override string ToSql(TableInfo tableInfo)
Parameters
Type Name Description
TableInfo tableInfo

The table to get the name for

Returns
Type Description
string

Name of the table like crm5."contact".

Overrides
Dialect.ToSql(TableInfo)

ToSql(Trim)

Trim in sybase: http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc38151.1510/html/iqrefbb/Trim.htm Trim in mysql: http://www.w3resource.com/mysql/string-functions/mysql-trim-function.php Oracle doc: http://www.techonthenet.com/oracle/functions/trim.php

Declaration
protected override string ToSql(Trim arg)
Parameters
Type Name Description
Trim arg
Returns
Type Description
string
Overrides
Dialect.ToSql(Trim)

ToSql(UnEqual)

You will never use the != ( not equal ) operator on anything else then fields and numeric parameters ( or possible other fields ). So we just return the arg.Left != arg.Right. If the right hand side isn't a numeric value, the return value is null.

Declaration
protected override string ToSql(UnEqual arg)
Parameters
Type Name Description
UnEqual arg
Returns
Type Description
string
Overrides
Dialect.ToSql(UnEqual)

ToSql(Upper)

ToSql( Upper arg ) will return the given argument anclosed by the SQL UPPER function.

Declaration
protected override string ToSql(Upper arg)
Parameters
Type Name Description
Upper arg

The argument to wrap UPPER around.

Returns
Type Description
string

The parsed UPPER-string

Overrides
Dialect.ToSql(Upper)

ToSql(WaitFor)

This class contains the common SQL-syntax for PostgreSQL.

Declaration
protected string ToSql(WaitFor arg)
Parameters
Type Name Description
WaitFor arg
Returns
Type Description
string

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top