1
- //
2
- // ServiceStack.OrmLite: Light-weight POCO ORM for .NET and Mono
3
- //
4
- // Authors:
5
- // Demis Bellot ([email protected] )
6
- //
7
- // Copyright 2010 Liquidbit Ltd.
8
- //
9
- // Licensed under the same terms of ServiceStack: new BSD license.
10
- //
11
-
12
- using System ;
13
- using System . Collections . Generic ;
14
- using System . Linq ;
15
- using ServiceStack . DataAnnotations ;
16
-
17
- namespace ServiceStack . OrmLite
18
- {
19
- public class ModelDefinition
20
- {
21
- public ModelDefinition ( )
22
- {
23
- this . FieldDefinitions = new List < FieldDefinition > ( ) ;
24
- this . CompositeIndexes = new List < CompositeIndexAttribute > ( ) ;
25
- }
26
-
27
- public string Name { get ; set ; }
28
-
29
- public string Alias { get ; set ; }
30
-
31
- public string Schema { get ; set ; }
32
-
33
- public bool IsInSchema { get { return this . Schema != null ; } }
34
-
35
- public string ModelName
36
- {
37
- get { return this . Alias ?? this . Name ; }
38
- }
39
-
40
- public Type ModelType { get ; set ; }
41
-
42
- public string SqlSelectAllFromTable { get ; set ; }
43
-
44
- public FieldDefinition PrimaryKey
45
- {
46
- get
47
- {
48
- return this . FieldDefinitions . First ( x => x . IsPrimaryKey ) ;
49
- }
50
- }
51
-
52
- public List < FieldDefinition > FieldDefinitions { get ; set ; }
53
-
54
- private FieldDefinition [ ] fieldDefinitionsArray ;
55
- public FieldDefinition [ ] FieldDefinitionsArray
56
- {
57
- get
58
- {
59
- if ( fieldDefinitionsArray == null )
60
- {
61
- fieldDefinitionsArray = FieldDefinitions . ToArray ( ) ;
62
- }
63
- return fieldDefinitionsArray ;
64
- }
65
- }
66
-
67
- public List < CompositeIndexAttribute > CompositeIndexes { get ; set ; }
68
- }
69
-
70
-
71
- public static class ModelDefinition < T >
72
- {
73
- private static ModelDefinition definition ;
74
- public static ModelDefinition Definition
75
- {
76
- get { return definition ?? ( definition = typeof ( T ) . GetModelDefinition ( ) ) ; }
77
- }
78
-
79
- private static string primaryKeyName ;
80
- public static string PrimaryKeyName
81
- {
82
- get { return primaryKeyName ?? ( primaryKeyName = Definition . PrimaryKey . FieldName ) ; }
83
- }
84
-
85
- }
1
+ //
2
+ // ServiceStack.OrmLite: Light-weight POCO ORM for .NET and Mono
3
+ //
4
+ // Authors:
5
+ // Demis Bellot ([email protected] )
6
+ //
7
+ // Copyright 2010 Liquidbit Ltd.
8
+ //
9
+ // Licensed under the same terms of ServiceStack: new BSD license.
10
+ //
11
+
12
+ using System ;
13
+ using System . Collections . Generic ;
14
+ using System . Linq ;
15
+ using ServiceStack . DataAnnotations ;
16
+
17
+ namespace ServiceStack . OrmLite
18
+ {
19
+ public class ModelDefinition
20
+ {
21
+ public ModelDefinition ( )
22
+ {
23
+ this . FieldDefinitions = new List < FieldDefinition > ( ) ;
24
+ this . IgnoredFieldDefinitions = new List < FieldDefinition > ( ) ;
25
+ this . CompositeIndexes = new List < CompositeIndexAttribute > ( ) ;
26
+ }
27
+
28
+ public string Name { get ; set ; }
29
+
30
+ public string Alias { get ; set ; }
31
+
32
+ public string Schema { get ; set ; }
33
+
34
+ public bool IsInSchema { get { return this . Schema != null ; } }
35
+
36
+ public string ModelName
37
+ {
38
+ get { return this . Alias ?? this . Name ; }
39
+ }
40
+
41
+ public Type ModelType { get ; set ; }
42
+
43
+ public string SqlSelectAllFromTable { get ; set ; }
44
+
45
+ public FieldDefinition PrimaryKey
46
+ {
47
+ get
48
+ {
49
+ return this . FieldDefinitions . First ( x => x . IsPrimaryKey ) ;
50
+ }
51
+ }
52
+
53
+ public List < FieldDefinition > FieldDefinitions { get ; set ; }
54
+
55
+ private FieldDefinition [ ] fieldDefinitionsArray ;
56
+ public FieldDefinition [ ] FieldDefinitionsArray
57
+ {
58
+ get
59
+ {
60
+ if ( fieldDefinitionsArray == null )
61
+ {
62
+ fieldDefinitionsArray = FieldDefinitions . ToArray ( ) ;
63
+ }
64
+ return fieldDefinitionsArray ;
65
+ }
66
+ }
67
+
68
+ public List < FieldDefinition > IgnoredFieldDefinitions { get ; set ; }
69
+
70
+ private FieldDefinition [ ] ignoredFieldDefinitionsArray ;
71
+ public FieldDefinition [ ] IgnoredFieldDefinitionsArray
72
+ {
73
+ get
74
+ {
75
+ if ( ignoredFieldDefinitionsArray == null )
76
+ {
77
+ ignoredFieldDefinitionsArray = IgnoredFieldDefinitions . ToArray ( ) ;
78
+ }
79
+ return ignoredFieldDefinitionsArray ;
80
+ }
81
+ }
82
+
83
+ private FieldDefinition [ ] allFieldDefinitionsArray ;
84
+ public FieldDefinition [ ] AllFieldDefinitionsArray
85
+ {
86
+ get
87
+ {
88
+ if ( allFieldDefinitionsArray == null )
89
+ {
90
+ List < FieldDefinition > allItems = new List < FieldDefinition > ( FieldDefinitions ) ;
91
+ allItems . AddRange ( IgnoredFieldDefinitions ) ;
92
+ allFieldDefinitionsArray = allItems . ToArray ( ) ;
93
+ }
94
+ return allFieldDefinitionsArray ;
95
+ }
96
+ }
97
+
98
+ public List < CompositeIndexAttribute > CompositeIndexes { get ; set ; }
99
+ }
100
+
101
+
102
+ public static class ModelDefinition < T >
103
+ {
104
+ private static ModelDefinition definition ;
105
+ public static ModelDefinition Definition
106
+ {
107
+ get { return definition ?? ( definition = typeof ( T ) . GetModelDefinition ( ) ) ; }
108
+ }
109
+
110
+ private static string primaryKeyName ;
111
+ public static string PrimaryKeyName
112
+ {
113
+ get { return primaryKeyName ?? ( primaryKeyName = Definition . PrimaryKey . FieldName ) ; }
114
+ }
115
+
116
+ }
86
117
}
0 commit comments