-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModel.cs
58 lines (48 loc) · 1.53 KB
/
Model.cs
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
using System.Collections.Generic;
using System.Linq;
namespace mysqldump2mssql
{
class Column
{
public string Name;
public string MySqlDatatype;
public string TSqlDatatype;
public bool Nullable;
public string Default;
public string Comment;
public bool Identity;
}
class Key
{
public string Name;
public List<string> Columns;
}
class ForeignKey
{
public string Name;
public string RefTable;
public class Column
{
public string Name;
public string RefName;
}
public List<Column> Columns;
public string OnDelete;
public string OnUpdate;
}
class Table
{
public string Schema;
public string Name;
public bool Utf8;
public string Comment;
public readonly List<Column> Columns = new List<Column>();
public readonly List<string> PrimaryKeyColumns = new List<string>();
public readonly List<Key> UniqueKeys = new List<Key>();
public readonly List<Key> Keys = new List<Key>();
public readonly List<ForeignKey> ForeignKeys = new List<ForeignKey>();
public readonly List<Key> FulltextKeys = new List<Key>();
public bool IdentityInsert { get { return Columns.Any(c => c.Identity); } }
public Column ColumnByName(string name) => Columns.FirstOrDefault(c => string.Compare(c.Name, name, true) == 0);
}
}