v1.2.10
This commit is contained in:
@@ -0,0 +1,288 @@
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Tue 6-Dec-2022 18:22:59
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Base.App
|
||||
{
|
||||
public class SaxDbDfn_Support
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Table identifiers.
|
||||
public enum TableIdx
|
||||
{
|
||||
Unknown = 0,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Column identifiers.
|
||||
public enum ColumnIdx
|
||||
{
|
||||
Unknown = 0,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private static readonly int tableCount = 0;
|
||||
private static readonly int columnCount = 0;
|
||||
private static ulong maxTextLen = 0;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve Table details (eg. name: 'Company').
|
||||
public static int GetTableCount ()
|
||||
{
|
||||
return tableCount;
|
||||
}
|
||||
public static String GetTableName (TableIdx table, bool delimitReservedWords = true)
|
||||
{
|
||||
int tableIdx = (int)table - 1;
|
||||
if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;
|
||||
String tableName = tables[(int)tableIdx];
|
||||
if (delimitReservedWords) tableName = DelimitReservedWord(tableName);
|
||||
return tableName;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Identify the table that corresponds with the specified column.
|
||||
public static TableIdx GetTableForColumn (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return TableIdx.Unknown;
|
||||
return columns[columnIdx].TableIdx;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve the specified Column's name (Qualified include table name: '(<Table>.Column>)').
|
||||
public static String GetColumnName (ColumnIdx column, bool delimitReservedWords = true)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return String.Empty;
|
||||
String columnName = columns[columnIdx].Name;
|
||||
if (delimitReservedWords) columnName = DelimitReservedWord(columnName);
|
||||
return columnName;
|
||||
}
|
||||
public static String GetColumnNameQual (ColumnIdx column, String tableAlias = "", bool braces = false)
|
||||
{
|
||||
String columnName = GetColumnName(column);
|
||||
if (!String.IsNullOrEmpty(columnName))
|
||||
{
|
||||
String tableName = StringUtil.EmptyOnNull(tableAlias);
|
||||
if (tableName.IsEmpty()) tableName = GetTableName(GetTableForColumn(column));
|
||||
columnName = tableName + (tableName.Length > 0 ? "." : "") + columnName;
|
||||
if (braces)
|
||||
columnName = "(" + columnName + ")";
|
||||
}
|
||||
return columnName;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Reserved words.
|
||||
private static DbReservedWordDelim reservedWordDelim = DbReservedWordDelim.SquareBrackets;
|
||||
public static void SetReservedWordDelim (DbReservedWordDelim reservedWordDelim)
|
||||
{
|
||||
SaxDbDfn_Support.reservedWordDelim = reservedWordDelim;
|
||||
}
|
||||
public static bool IsReservedWord (String word)
|
||||
{
|
||||
if (String.IsNullOrEmpty(word)) return false;
|
||||
if (reservedWords.Contains(word, StringComparer.OrdinalIgnoreCase)) return true;
|
||||
return false;
|
||||
}
|
||||
public static String DelimitReservedWord (String word)
|
||||
{
|
||||
if (!IsReservedWord(word)) return word;
|
||||
switch (reservedWordDelim)
|
||||
{
|
||||
case DbReservedWordDelim.None:
|
||||
break;
|
||||
case DbReservedWordDelim.DoubleQuotes:
|
||||
word = "\"" + word + "\"";
|
||||
break;
|
||||
case DbReservedWordDelim.SquareBrackets:
|
||||
default:
|
||||
word = "[" + word + "]";
|
||||
break;
|
||||
}
|
||||
return word;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve information about the specified Column.
|
||||
public static DbColumnDataType GetColDataType (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return DbColumnDataType.Unknown;
|
||||
return columns[columnIdx].DataType;
|
||||
}
|
||||
public static short GetColNativeDataType (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return 0;
|
||||
return columns[columnIdx].NativeDataType;
|
||||
}
|
||||
public static void SetMaxTextLen (ulong maxTextLen)
|
||||
{
|
||||
SaxDbDfn_Support.maxTextLen = maxTextLen;
|
||||
}
|
||||
public static bool IsColFmtText (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return false;
|
||||
return (columns[columnIdx].DataType == DbColumnDataType.VarChar);
|
||||
}
|
||||
public static ulong GetColTextLen (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return 0;
|
||||
if (columns[columnIdx].DataType == DbColumnDataType.VarChar)
|
||||
{
|
||||
ulong textLen = columns[columnIdx].DataLen;
|
||||
if (maxTextLen > 0 && textLen > maxTextLen) textLen = maxTextLen;
|
||||
return textLen;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public static bool IsColFmtBool (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return false;
|
||||
return (columns[columnIdx].DataType == DbColumnDataType.Bit);
|
||||
}
|
||||
public static bool IsColFmtNumeric (ColumnIdx column)
|
||||
{
|
||||
int columnIdx = (int)column - 1;
|
||||
if (columnIdx < 0 || columnIdx >= columnCount) return false;
|
||||
switch (columns[columnIdx].DataType)
|
||||
{
|
||||
case DbColumnDataType.TinyInt:
|
||||
case DbColumnDataType.SmallInt:
|
||||
case DbColumnDataType.Int:
|
||||
case DbColumnDataType.BigInt:
|
||||
case DbColumnDataType.Single:
|
||||
case DbColumnDataType.Double:
|
||||
case DbColumnDataType.Decimal:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Table definitions.
|
||||
private static readonly String[] tables =
|
||||
{
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Table column definitions.
|
||||
private class ColumnDfn
|
||||
{
|
||||
internal TableIdx TableIdx { get; set; }
|
||||
internal String Name { get; set; }
|
||||
internal DbColumnDataType DataType { get; set; }
|
||||
internal short NativeDataType { get; set; }
|
||||
internal bool IsIdentity { get; set; }
|
||||
internal ulong DataLen { get; set; }
|
||||
internal ColumnDfn (int tableIdx, String name, int dataType, short nativeDataType, bool isIdentity, ulong dataLen)
|
||||
{
|
||||
this.TableIdx = (TableIdx)tableIdx;
|
||||
this.Name = name;
|
||||
this.DataType = (DbColumnDataType)dataType;
|
||||
this.NativeDataType = nativeDataType;
|
||||
this.IsIdentity = isIdentity;
|
||||
this.DataLen = dataLen;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private static readonly ColumnDfn[] columns =
|
||||
{
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Reserved words.
|
||||
private static readonly List<String> reservedWords = new List<String>()
|
||||
{
|
||||
"ADD",
|
||||
"ALL",
|
||||
"ALTER",
|
||||
"AND",
|
||||
"ANY",
|
||||
"AS",
|
||||
"ASC",
|
||||
"AVG",
|
||||
"BEGIN",
|
||||
"BETWEEN",
|
||||
"BY",
|
||||
"CASE",
|
||||
"CAST",
|
||||
"COLUMN",
|
||||
"COMMIT",
|
||||
"CONSTRAINT",
|
||||
"CONVERT",
|
||||
"COUNT",
|
||||
"CREATE",
|
||||
"CURRENCY",
|
||||
"DEFAULT",
|
||||
"DELETE",
|
||||
"DESC",
|
||||
"DISTINCT",
|
||||
"DROP",
|
||||
"ELSE",
|
||||
"END",
|
||||
"EXECUTE",
|
||||
"EXISTS",
|
||||
"FALSE",
|
||||
"FROM",
|
||||
"GRANT",
|
||||
"GROUP",
|
||||
"HAVING",
|
||||
"IN",
|
||||
"INDEX",
|
||||
"INNER",
|
||||
"INSERT",
|
||||
"INTO",
|
||||
"IS",
|
||||
"JOIN",
|
||||
"KEY",
|
||||
"LEFT",
|
||||
"LIKE",
|
||||
"MAX",
|
||||
"MIN",
|
||||
"NOT",
|
||||
"NULL",
|
||||
"ON",
|
||||
"OR",
|
||||
"ORDER",
|
||||
"OUTER",
|
||||
"OUTPUT",
|
||||
"PRIMARY",
|
||||
"PROCEDURE",
|
||||
"REVOKE",
|
||||
"ROLLBACK",
|
||||
"ROWCOUNT",
|
||||
"SELECT",
|
||||
"SET",
|
||||
"SQL",
|
||||
"SUM",
|
||||
"TABLE",
|
||||
"THEN",
|
||||
"TRANSACTION",
|
||||
"TRUE",
|
||||
"UNION",
|
||||
"UNIQUE",
|
||||
"UPDATE",
|
||||
"USER",
|
||||
"VALUES",
|
||||
"VIEW",
|
||||
"WHEN",
|
||||
"WHERE",
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user