This repository was archived by the owner on Oct 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabase.cs
More file actions
87 lines (67 loc) · 1.83 KB
/
Database.cs
File metadata and controls
87 lines (67 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System.Collections.Generic;
using System.Data;
using System;
namespace Xevle.Database
{
public abstract class Database
{
#region Properties
public bool Connected { get; protected set; }
#endregion
#region Abstract methods
#region Connection
public abstract bool Connect();
public abstract void Disconnect();
#endregion
#region Queries
public abstract int ExecuteNonQuery(string sqlCommand);
public abstract DataTable ExecuteQuery(string sqlCommand);
#endregion
#region Edits
public abstract void InsertData(DataTable insertData);
public abstract void UpdateData(DataTable updateData, string primaryKey);
public abstract void RemoveData(string table, string key, string value);
#endregion
#region Transactions
public abstract void StartTransaction();
public abstract void CommitTransaction();
#endregion
#region Tables
public abstract void CreateTable(DataTable table);
public void CreateTables(List<DataTable> tables)
{
foreach (DataTable i in tables)
{
CreateTable(i);
}
}
public abstract void RemoveTable(string tableName);
public void RemoveTables(List<string> tables)
{
foreach (string table in tables)
{
RemoveTable(table);
}
}
public abstract List<string> GetTables();
public DataTable GetTable(string tableName)
{
string sqlCommand = String.Format("SELECT * FROM \"{0}\";", tableName);
DataTable ret = ExecuteQuery(sqlCommand);
ret.TableName = tableName;
return ret;
}
public abstract DataTable GetTableStructure(string tableName);
public bool ExistsTable(string tableName)
{
List<string> tables = GetTables();
if (tables.IndexOf(tableName) == -1) return false;
return true;
}
#endregion
#region Misc methods
public abstract string GetDatabaseSystemDataType(string datatype);
#endregion
#endregion
}
}