-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEbDataTable.cs
More file actions
129 lines (105 loc) · 3.08 KB
/
EbDataTable.cs
File metadata and controls
129 lines (105 loc) · 3.08 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using ExpressBase.Common.Structures;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ExpressBase.Common.Extensions;
namespace ExpressBase.Common
{
[ProtoBuf.ProtoContract]
public class EbDataTable
{
internal EbDataSet DataSet { get; set; }
[ProtoBuf.ProtoMember(1)]
public string TableName { get; set; }
[ProtoBuf.ProtoMember(2)]
public ColumnColletion Columns { get; set; }
[ProtoBuf.ProtoMember(3)]
public RowColletion Rows { get; set; }
public EbDataTable()
{
this.Columns = new ColumnColletion(this);
this.Rows = new RowColletion(this);
}
public EbDataTable(string tablename)
{
this.TableName = tablename;
this.Columns = new ColumnColletion(this);
this.Rows = new RowColletion(this);
}
public EbDataRow NewDataRow()
{
//EbDataRow dr = new EbDataRow(this.Columns.Count);
return new EbDataRow();
}
public EbDataRow NewDataRow2()
{
return new EbDataRow(this.Columns.Count);
}
public EbDataTable GetEmptyTable()
{
EbDataTable __newTable = new EbDataTable();
EbDataColumn[] dataColumns = new EbDataColumn[this.Columns.Count];
this.Columns.CopyTo(dataColumns);
foreach(EbDataColumn col in dataColumns)
__newTable.Columns.Add(col);
return __newTable;
}
public EbDataColumn NewDataColumn(int index, string name, EbDbTypes type)
{
return new EbDataColumn(index, name, type);
}
}
public class TableColletion : List<EbDataTable>
{
internal EbDataSet DataSet { get; set; }
public TableColletion() { }
public TableColletion(EbDataSet dataset)
{
this.DataSet = dataset;
}
public void Add(string tablename, EbDataTable dt)
{
if (dt.TableName == null || tablename == null)
{
tablename = "Table" + (this.DataSet.Tables.Count + 1).ToString();
dt.TableName = tablename;
dt.DataSet = this.DataSet;
}
base.Add(dt);
}
new public void Add(EbDataTable dt)
{
this.Add(dt.TableName, dt);
}
public void Remove(string tablename)
{
EbDataTable _toRemoveTable = null;
foreach (EbDataTable table in this)
{
if (table.TableName == tablename)
{
_toRemoveTable = table;
break;
}
}
base.Remove(_toRemoveTable);
}
new public void Remove(EbDataTable dt)
{
base.Remove(dt);
}
public EbDataTable this[string tablename]
{
get
{
foreach (EbDataTable table in this)
{
if (table.TableName == tablename)
return table;
}
return null;
}
}
}
}