1.2.11.4
This commit is contained in:
@@ -0,0 +1,488 @@
|
||||
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 Wed 22-May-2024 12:21:55
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Saxonite.Base.App
|
||||
{
|
||||
public class SaxDbDfn_Reference
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Table identifiers.
|
||||
public enum TableIdx
|
||||
{
|
||||
Unknown = 0,
|
||||
UsgaCountry,
|
||||
UsgaCourse,
|
||||
UsgaFacility,
|
||||
UsgaMarker,
|
||||
UsgaProvince,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Column identifiers.
|
||||
public enum ColumnIdx
|
||||
{
|
||||
Unknown = 0,
|
||||
UsgaCountry_Id,
|
||||
UsgaCountry_CountryCode,
|
||||
UsgaCountry_CountryName,
|
||||
UsgaCountry_EntCountryCode,
|
||||
UsgaCountry_Notes,
|
||||
UsgaCountry_Flags,
|
||||
UsgaCountry_Status,
|
||||
UsgaCountry_CreateOn,
|
||||
UsgaCountry_CreateBy,
|
||||
UsgaCountry_CreateHost,
|
||||
UsgaCountry_UpdateOn,
|
||||
UsgaCountry_UpdateBy,
|
||||
UsgaCountry_UpdateHost,
|
||||
UsgaCourse_Id,
|
||||
UsgaCourse_FacilityId,
|
||||
UsgaCourse_CourseId,
|
||||
UsgaCourse_LegacyCrpCourseId,
|
||||
UsgaCourse_Caption,
|
||||
UsgaCourse_CourseName,
|
||||
UsgaCourse_FullName,
|
||||
UsgaCourse_Address1,
|
||||
UsgaCourse_Address2,
|
||||
UsgaCourse_City,
|
||||
UsgaCourse_Email,
|
||||
UsgaCourse_Telephone,
|
||||
UsgaCourse_Notes,
|
||||
UsgaCourse_Flags,
|
||||
UsgaCourse_Status,
|
||||
UsgaCourse_CreateOn,
|
||||
UsgaCourse_CreateBy,
|
||||
UsgaCourse_CreateHost,
|
||||
UsgaCourse_UpdateOn,
|
||||
UsgaCourse_UpdateBy,
|
||||
UsgaCourse_UpdateHost,
|
||||
UsgaFacility_Id,
|
||||
UsgaFacility_ProvinceId,
|
||||
UsgaFacility_FacilityId,
|
||||
UsgaFacility_FacilityName,
|
||||
UsgaFacility_Notes,
|
||||
UsgaFacility_Flags,
|
||||
UsgaFacility_Status,
|
||||
UsgaFacility_CreateOn,
|
||||
UsgaFacility_CreateBy,
|
||||
UsgaFacility_CreateHost,
|
||||
UsgaFacility_UpdateOn,
|
||||
UsgaFacility_UpdateBy,
|
||||
UsgaFacility_UpdateHost,
|
||||
UsgaMarker_Id,
|
||||
UsgaMarker_CourseId,
|
||||
UsgaMarker_MarkerId,
|
||||
UsgaMarker_Caption,
|
||||
UsgaMarker_Holes,
|
||||
UsgaMarker_HolesCaption,
|
||||
UsgaMarker_Tee,
|
||||
UsgaMarker_Gender,
|
||||
UsgaMarker_SlopeRating,
|
||||
UsgaMarker_Par,
|
||||
UsgaMarker_CourseRating,
|
||||
UsgaMarker_BogeyRating,
|
||||
UsgaMarker_Length,
|
||||
UsgaMarker_Notes,
|
||||
UsgaMarker_Flags,
|
||||
UsgaMarker_Status,
|
||||
UsgaMarker_CreateOn,
|
||||
UsgaMarker_CreateBy,
|
||||
UsgaMarker_CreateHost,
|
||||
UsgaMarker_UpdateOn,
|
||||
UsgaMarker_UpdateBy,
|
||||
UsgaMarker_UpdateHost,
|
||||
UsgaProvince_Id,
|
||||
UsgaProvince_CountryId,
|
||||
UsgaProvince_ProvinceCode,
|
||||
UsgaProvince_EntProvinceCode,
|
||||
UsgaProvince_ProvinceName,
|
||||
UsgaProvince_Notes,
|
||||
UsgaProvince_Flags,
|
||||
UsgaProvince_Status,
|
||||
UsgaProvince_CreateOn,
|
||||
UsgaProvince_CreateBy,
|
||||
UsgaProvince_CreateHost,
|
||||
UsgaProvince_UpdateOn,
|
||||
UsgaProvince_UpdateBy,
|
||||
UsgaProvince_UpdateHost,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private static readonly int tableCount = 5;
|
||||
private static readonly int columnCount = 83;
|
||||
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].Name;
|
||||
if (delimitReservedWords) tableName = DelimitReservedWord(tableName);
|
||||
return tableName;
|
||||
}
|
||||
public static String GetTableNameQual (TableIdx table, bool delimitReservedWords = true)
|
||||
{
|
||||
int tableIdx = (int)table - 1;
|
||||
if (tableIdx < 0 || tableIdx >= tableCount) return String.Empty;
|
||||
String schemaName = tables[(int)tableIdx].Schema;
|
||||
String tableName = tables[(int)tableIdx].Name;
|
||||
if (delimitReservedWords) { schemaName = DelimitReservedWord(schemaName); tableName = DelimitReservedWord(tableName); }
|
||||
return (StringUtil.IsBlank(schemaName) ? "" : schemaName + ".") + 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_Reference.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)
|
||||
{
|
||||
return IsReservedWord(word) ? DelimitWord(word) : word;
|
||||
}
|
||||
public static String DelimitWord (String word)
|
||||
{
|
||||
return DelimitWord(word, reservedWordDelim);
|
||||
}
|
||||
public static String DelimitWord (String word, DbReservedWordDelim wordDelim)
|
||||
{
|
||||
switch (wordDelim)
|
||||
{
|
||||
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_Reference.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 class TableDfn
|
||||
{
|
||||
internal String Schema { get; set; }
|
||||
internal String Name { get; set; }
|
||||
internal TableDfn (String schema, String name)
|
||||
{
|
||||
this.Schema= schema;
|
||||
this.Name = name;
|
||||
}
|
||||
}
|
||||
private static readonly TableDfn[] tables =
|
||||
{
|
||||
new TableDfn("golf","UsgaCountry"),
|
||||
new TableDfn("golf","UsgaCourse"),
|
||||
new TableDfn("golf","UsgaFacility"),
|
||||
new TableDfn("golf","UsgaMarker"),
|
||||
new TableDfn("golf","UsgaProvince"),
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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 =
|
||||
{
|
||||
new ColumnDfn(1,"Id",5,-5,true,19),
|
||||
new ColumnDfn(1,"CountryCode",0,12,false,10),
|
||||
new ColumnDfn(1,"CountryName",0,-9,false,200),
|
||||
new ColumnDfn(1,"EntCountryCode",0,12,false,10),
|
||||
new ColumnDfn(1,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(1,"Flags",3,5,false,5),
|
||||
new ColumnDfn(1,"Status",0,12,false,3),
|
||||
new ColumnDfn(1,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(1,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(1,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(1,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(1,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(1,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(2,"Id",5,-5,true,19),
|
||||
new ColumnDfn(2,"FacilityId",5,-5,false,19),
|
||||
new ColumnDfn(2,"CourseId",5,-5,false,19),
|
||||
new ColumnDfn(2,"LegacyCrpCourseId",5,-5,false,19),
|
||||
new ColumnDfn(2,"Caption",0,-9,false,200),
|
||||
new ColumnDfn(2,"CourseName",0,-9,false,200),
|
||||
new ColumnDfn(2,"FullName",0,-9,false,200),
|
||||
new ColumnDfn(2,"Address1",0,-9,false,200),
|
||||
new ColumnDfn(2,"Address2",0,-9,false,200),
|
||||
new ColumnDfn(2,"City",0,-9,false,200),
|
||||
new ColumnDfn(2,"Email",0,-9,false,200),
|
||||
new ColumnDfn(2,"Telephone",0,-9,false,200),
|
||||
new ColumnDfn(2,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(2,"Flags",3,5,false,5),
|
||||
new ColumnDfn(2,"Status",0,12,false,3),
|
||||
new ColumnDfn(2,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(2,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(2,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(2,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(2,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(2,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(3,"Id",5,-5,true,19),
|
||||
new ColumnDfn(3,"ProvinceId",5,-5,false,19),
|
||||
new ColumnDfn(3,"FacilityId",5,-5,false,19),
|
||||
new ColumnDfn(3,"FacilityName",0,-9,false,200),
|
||||
new ColumnDfn(3,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(3,"Flags",3,5,false,5),
|
||||
new ColumnDfn(3,"Status",0,12,false,3),
|
||||
new ColumnDfn(3,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(3,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(3,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(3,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(3,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(3,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(4,"Id",5,-5,true,19),
|
||||
new ColumnDfn(4,"CourseId",5,-5,false,19),
|
||||
new ColumnDfn(4,"MarkerId",5,-5,false,19),
|
||||
new ColumnDfn(4,"Caption",0,-9,false,200),
|
||||
new ColumnDfn(4,"Holes",3,5,false,5),
|
||||
new ColumnDfn(4,"HolesCaption",0,-9,false,32),
|
||||
new ColumnDfn(4,"Tee",0,-9,false,32),
|
||||
new ColumnDfn(4,"Gender",0,-9,false,32),
|
||||
new ColumnDfn(4,"SlopeRating",3,5,false,5),
|
||||
new ColumnDfn(4,"Par",3,5,false,5),
|
||||
new ColumnDfn(4,"CourseRating",8,3,false,9),
|
||||
new ColumnDfn(4,"BogeyRating",8,3,false,9),
|
||||
new ColumnDfn(4,"Length",3,5,false,5),
|
||||
new ColumnDfn(4,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(4,"Flags",3,5,false,5),
|
||||
new ColumnDfn(4,"Status",0,12,false,3),
|
||||
new ColumnDfn(4,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(4,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(4,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(4,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(4,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(4,"UpdateHost",0,12,false,100),
|
||||
new ColumnDfn(5,"Id",5,-5,true,19),
|
||||
new ColumnDfn(5,"CountryId",5,-5,false,19),
|
||||
new ColumnDfn(5,"ProvinceCode",0,12,false,20),
|
||||
new ColumnDfn(5,"EntProvinceCode",0,12,false,20),
|
||||
new ColumnDfn(5,"ProvinceName",0,-9,false,200),
|
||||
new ColumnDfn(5,"Notes",0,-9,false,2000),
|
||||
new ColumnDfn(5,"Flags",3,5,false,5),
|
||||
new ColumnDfn(5,"Status",0,12,false,3),
|
||||
new ColumnDfn(5,"CreateOn",9,93,false,23),
|
||||
new ColumnDfn(5,"CreateBy",4,4,false,10),
|
||||
new ColumnDfn(5,"CreateHost",0,12,false,100),
|
||||
new ColumnDfn(5,"UpdateOn",9,93,false,23),
|
||||
new ColumnDfn(5,"UpdateBy",4,4,false,10),
|
||||
new ColumnDfn(5,"UpdateHost",0,12,false,100),
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// 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