forked from praeclarum/sqlite-net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImplicitChanges.txt
80 lines (68 loc) · 3 KB
/
ImplicitChanges.txt
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
76
[Flags]
public enum CreateFlags
{
None = 0,
ImplicitPK = 1, // create a primary key for field called 'Id'
ImplicitIndex = 2, // create an index for fields ending in 'Id'
AllImplicit = 3, // do both above
AutoIncPK = 4 // force PK field to be auto inc
}
233
public TableMapping GetMapping (Type type, CreateFlags createFlags = CreateFlags.None)
{
if (_mappings == null) {
_mappings = new Dictionary<string, TableMapping> ();
}
TableMapping map;
if (!_mappings.TryGetValue (type.FullName, out map)) {
map = new TableMapping (type, createFlags);
_mappings [type.FullName] = map;
}
return map;
}
293
public int CreateTable<T>(CreateFlags createFlags = CreateFlags.None)
{
return CreateTable(typeof (T), createFlags);
}
308
public int CreateTable(Type ty, CreateFlags createFlags = CreateFlags.None)
{
if (_tables == null) {
_tables = new Dictionary<string, TableMapping> ();
}
TableMapping map;
if (!_tables.TryGetValue (ty.FullName, out map)) {
map = GetMapping(ty, createFlags);
1436
public TableMapping (Type type, CreateFlags createFlags = CreateFlags.None)
1464
cols.Add (new Column (p, createFlags));
1603
public Column (PropertyInfo prop, CreateFlags createFlags = CreateFlags.None)
{
var colAttr = (ColumnAttribute)prop.GetCustomAttributes (typeof(ColumnAttribute), true).FirstOrDefault ();
_prop = prop;
Name = colAttr == null ? prop.Name : colAttr.Name;
//If this type is Nullable<T> then Nullable.GetUnderlyingType returns the T, otherwise it returns null, so get the actual type instead
ColumnType = Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType;
Collation = Orm.Collation (prop);
IsAutoInc = Orm.IsAutoInc (prop);
IsPK = Orm.IsPK (prop) || (((createFlags & CreateFlags.ImplicitPK) == CreateFlags.ImplicitPK) && prop.Name == Orm.ImplicitPkName);
IsAutoInc = Orm.IsAutoInc(prop) || (IsPK && ((createFlags & CreateFlags.AutoIncPK) == CreateFlags.AutoIncPK));
Indices = Orm.GetIndices(prop);
if (!Indices.Any()
&& !IsPK
&& ((createFlags & CreateFlags.ImplicitIndex) == CreateFlags.ImplicitIndex)
&& Name.EndsWith(Orm.ImplicitIndexSuffix)
)
{
Indices = new IndexedAttribute[] {new IndexedAttribute()};
}
IsNullable = !IsPK;
MaxStringLength = Orm.MaxStringLength (prop);
}
1643
public const string ImplicitPkName = "Id";
public const string ImplicitIndexSuffix = "Id";