18using System.Collections.Generic;
20using System.Data.SqlClient;
23using System.Threading.Tasks;
28 internal class DatabaseSettings
30 public GPALDatabase Database {
get;
set; }
31 public DatabaseType DatabaseType {
get;
set; }
32 public string DatabaseName {
get;
set; }
33 public string TableName {
get;
set; }
34 public string ServerName {
get;
set; }
35 public string UserName {
get;
set; }
36 public string Password {
get;
set; }
37 public SqlConnection Connection {
get;
set; }
38 public SqlTransaction SqlTransaction {
get;
set; }
39 public string ConnectionString {
get;
set; }
40 private string ExecutionString {
get;
set; } =
null;
41 public string CreateSQL {
get;
set; } =
null;
42 public string ReadSQL {
get;
set; } =
null;
43 public string UpdateSQL {
get;
set; } =
null;
44 public string DeleteSQL {
get;
set; } =
null;
45 public System.Data.CommandType SqlCommandType {
get;
set; } = CommandType.Text;
46 public List<DatabaseColumn> ColumnList {
get;
set; }
47 public List<string> ParameterNamesList {
get;
set; }
48 public List<string> ParametersList {
get;
set; }
49 public IGPALGrid<string> ParametersGrid {
get;
set; }
50 public GPALDatabase.DatabaseError LastError {
get;
set; }
51 public IGPALGrid<string> Tokens {
get;
set; }
52 public List<int> LastGridRowCountsPerTable {
get;
set; }
53 public int RowCount {
get;
set; } = -1;
54 public int CommandTimeoutSeconds {
get;
set; } = -1;
55 public GPALDatabase.CallOnError CallOnErrorHandler {
get;
set; } =
null;
56 public string StoredProcedure
60 return ExecutionString;
64 SqlCommandType = CommandType.StoredProcedure;
65 ExecutionString = value;
68 public string SqlCommand
72 return ExecutionString;
76 SqlCommandType = CommandType.Text;
77 ExecutionString = value;
84 internal enum CrudVerb { None, Create, Read, Update, Delete }
91 internal CrudVerb Verb {
get;
set; } = CrudVerb.None;
96 internal string VerbSQL
100 string retVal = CrudVerb.Create == Verb ? CreateSQL
101 : CrudVerb.Read == Verb ? ReadSQL
102 : CrudVerb.Update == Verb ? UpdateSQL
103 : CrudVerb.Delete == Verb ? DeleteSQL
109 internal class DatabaseColumn
111 public string ColumnName {
get;
set; } =
null;
112 public SqlDbType ColumnType {
get;
set; }
113 public int ColumnLength {
get;
set; }
114 public int ColumnPrecision {
get;
set; }
115 public int ColumnScale {
get;
set; }
116 public string TvTableTypeName {
get;
set; }
117 public DatabaseColumn(
string name)
121 public DatabaseColumn(
string name, SqlDbType sqlDbType)
124 ColumnType = sqlDbType;
127 public DatabaseSettings(GPALDatabase database)
129 ColumnList =
new List<DatabaseColumn>();
130 ParameterNamesList =
new List<string>();
131 ParametersList =
new List<string>();
132 ParametersGrid = GPAL.Grid.ToGPALObject();
133 Tokens = GPAL.Grid.ToGPALObject();