@@ -8,176 +8,58 @@ namespace Dotmim.Sync.Manager
8
8
{
9
9
public abstract class DbMetadata
10
10
{
11
+
11
12
/// <summary>
12
13
/// Validate if a column definition is actualy supported by the provider
13
14
/// </summary>
14
15
public abstract bool IsValid ( SyncColumn columnDefinition ) ;
15
16
16
17
/// <summary>
17
- /// Get the datastore type name from a DbType for generating scripts
18
- /// </summary>
19
- public abstract string GetStringFromDbType ( DbType dbType , int maxLength ) ;
20
-
21
- /// <summary>
22
- /// Get the datastore type name from a provider dbType for generating scripts
23
- /// </summary>
24
- public abstract string GetStringFromOwnerDbType ( object ownerType ) ;
25
-
26
- /// <summary>
27
- /// Get the datastore precision / scale / length string for generating scripts
28
- /// </summary>
29
- public abstract string GetPrecisionStringFromDbType ( DbType dbType , int maxLength , byte precision , byte scale ) ;
30
-
31
- /// <summary>
32
- /// Get the datastore precision / scale / length string for generating scripts
33
- /// </summary>
34
- public abstract string GetPrecisionStringFromOwnerDbType ( object dbType , int maxLength , byte precision , byte scale ) ;
35
-
36
- /// <summary>
37
- /// Get the datastore precision / scale / length for DbParameter
38
- /// </summary>
39
- public abstract ( byte precision , byte scale ) GetPrecisionFromOwnerDbType ( object dbType , byte precision , byte scale ) ;
40
-
41
- /// <summary>
42
- /// Get the datastore precision / scale for DbParameter
43
- /// </summary>
44
- public abstract ( byte precision , byte scale ) GetPrecisionFromDbType ( DbType dbType , byte precision , byte scale ) ;
45
-
46
- /// <summary>
47
- /// Get the datastore MaxLength for DbParameter
18
+ /// Gets and validate a max length issued from the database definition
48
19
/// </summary>
49
- public abstract Int32 GetMaxLengthFromDbType ( DbType dbType , Int32 maxLength ) ;
20
+ public abstract int GetMaxLength ( SyncColumn columnDefinition ) ;
50
21
51
22
/// <summary>
52
- /// Get the datastore maxLength for DbParameter
23
+ /// Get the native datastore DbType (that's why we return object instead of SqlDbType or SqliteDbType or MySqlDbType)
53
24
/// </summary>
54
- public abstract Int32 GetMaxLengthFromOwnerDbType ( object dbType , Int32 maxLength ) ;
25
+ public abstract object GetOwnerDbType ( SyncColumn columnDefinition ) ;
55
26
56
27
/// <summary>
57
28
/// Get a DbType from a datastore type name
58
29
/// </summary>
59
- public abstract DbType ValidateDbType ( string typeName , bool isUnsigned , bool isUnicode , long maxLength ) ;
60
-
61
- /// <summary>
62
- /// Get a datastore DbType from a datastore type name
63
- /// </summary>
64
- public abstract object ValidateOwnerDbType ( string typeName , bool isUnsigned , bool isUnicode , long maxLength ) ;
30
+ public abstract DbType GetDbType ( SyncColumn columnDefinition ) ;
65
31
66
32
/// <summary>
67
- /// Gets and validate a max length issued from the database definition
68
- /// </summary>
69
- public abstract int ValidateMaxLength ( string typeName , bool isUnsigned , bool isUnicode , long maxLength ) ;
70
-
71
- /// <summary>
72
- /// Gets the corresponding DbType from a owner dbtype
73
- /// </summary>
74
- public abstract object GetOwnerDbTypeFromDbType ( DbType dbType ) ;
75
-
76
- /// <summary>
77
- /// Get a managed type from a datastore dbType
33
+ /// Validate if a column is readonly or not
78
34
/// </summary>
79
- public abstract Type ValidateType ( object ownerType ) ;
35
+ /// <param name="columnDefinition"></param>
36
+ /// <returns></returns>
37
+ public abstract bool IsReadonly ( SyncColumn columnDefinition ) ;
80
38
81
39
/// <summary>
82
40
/// Check if a type name is a numeric type
83
41
/// </summary>
84
- public abstract bool IsNumericType ( string typeName ) ;
85
-
86
- /// <summary>
87
- /// Check if a type name is a text type
88
- /// </summary>
89
- public abstract bool IsTextType ( string typeName ) ;
42
+ public abstract bool IsNumericType ( SyncColumn columnDefinition ) ;
90
43
91
44
/// <summary>
92
45
/// Check if a type name support scale
93
46
/// </summary>
94
- public abstract bool SupportScale ( string typeName ) ;
47
+ public abstract bool IsSupportingScale ( SyncColumn columnDefinition ) ;
95
48
96
49
/// <summary>
97
50
/// Get precision and scale from a SchemaColumn
98
51
/// </summary>
99
- public abstract ( byte precision , byte scale ) ValidatePrecisionAndScale ( SyncColumn columnDefinition ) ;
52
+ public abstract ( byte precision , byte scale ) GetPrecisionAndScale ( SyncColumn columnDefinition ) ;
100
53
101
54
/// <summary>
102
55
/// Get precision if supported (MySql supports int(10))
103
56
/// </summary>
104
- public abstract byte ValidatePrecision ( SyncColumn columnDefinition ) ;
105
-
106
-
107
- /// <summary>
108
- /// Validate if a column is readonly or not
109
- /// </summary>
110
- /// <param name="columnDefinition"></param>
111
- /// <returns></returns>
112
- public abstract bool ValidateIsReadonly ( SyncColumn columnDefinition ) ;
57
+ public abstract byte GetPrecision ( SyncColumn columnDefinition ) ;
113
58
114
59
/// <summary>
115
- /// Returns the corresponding Owner DbType. Because it could be lower case, we should handle it
60
+ /// Get a managed type from a datastore dbType
116
61
/// </summary>
117
- public object TryGetOwnerDbType ( string ownerDbType , DbType fallbackDbType , bool isUnsigned , bool isUnicode , long maxLength , string fromProviderType , string ownerProviderType )
118
- {
119
- // We MUST check if we are from the same provider (if it's mysql or oracle, we fallback on dbtype
120
- if ( ! string . IsNullOrEmpty ( ownerDbType ) && fromProviderType == ownerProviderType )
121
- return ValidateOwnerDbType ( ownerDbType , isUnsigned , isUnicode , maxLength ) ;
122
-
123
- // if it's not the same provider, fallback on DbType instead.
124
- return GetOwnerDbTypeFromDbType ( fallbackDbType ) ;
125
- }
126
-
127
- public string TryGetOwnerDbTypeString ( string originalDbType , DbType fallbackDbType , bool isUnsigned , bool isUnicode , long maxLength , string fromProviderType , string ownerProviderType )
128
- {
129
- // We MUST check if we are from the same provider (if it's mysql or oracle, we fallback on dbtype
130
- if ( ! String . IsNullOrEmpty ( originalDbType ) && fromProviderType == ownerProviderType )
131
- {
132
- Object ownedDbType = ValidateOwnerDbType ( originalDbType , isUnsigned , isUnicode , maxLength ) ;
133
- return GetStringFromOwnerDbType ( ownedDbType ) ;
134
- }
135
-
136
- // if it's not the same provider, fallback on DbType instead.
137
- return GetStringFromDbType ( fallbackDbType , Convert . ToInt32 ( maxLength ) ) ;
138
- }
139
-
140
- public string TryGetOwnerDbTypePrecision ( string originalDbType , DbType fallbackDbType , bool isUnsigned , bool isUnicode , int maxLength , byte precision , byte scale , string fromProviderType , string ownerProviderType )
141
- {
142
- // We MUST check if we are from the same provider (if it's mysql or oracle, we fallback on dbtype
143
- if ( ! String . IsNullOrEmpty ( originalDbType ) && fromProviderType == ownerProviderType )
144
- {
145
- object ownedDbType = ValidateOwnerDbType ( originalDbType , isUnsigned , isUnicode , maxLength ) ;
146
- return GetPrecisionStringFromOwnerDbType ( ownedDbType , maxLength , precision , scale ) ;
147
- }
148
-
149
- // if it's not the same provider, fallback on DbType instead.
150
- return GetPrecisionStringFromDbType ( fallbackDbType , maxLength , precision , scale ) ;
151
- }
152
-
153
- public ( byte precision , byte scale ) TryGetOwnerPrecisionAndScale ( string originalDbType , DbType fallbackDbType , bool isUnsigned , bool isUnicode , long maxLength , byte precision , byte scale , string fromProviderType , string ownerProviderType )
154
- {
155
- // We MUST check if we are from the same provider (if it's mysql or oracle, we fallback on dbtype
156
- if ( ! String . IsNullOrEmpty ( originalDbType ) && fromProviderType == ownerProviderType )
157
- {
158
- Object ownedDbType = ValidateOwnerDbType ( originalDbType , isUnsigned , isUnicode , maxLength ) ;
159
- return GetPrecisionFromOwnerDbType ( ownedDbType , precision , scale ) ;
160
- }
161
-
162
- // if it's not the same provider, fallback on DbType instead.
163
- return GetPrecisionFromDbType ( fallbackDbType , precision , scale ) ;
164
-
165
- }
166
-
167
- public int TryGetOwnerMaxLength ( string originalDbType , DbType fallbackDbType , bool isUnsigned , bool isUnicode , int maxLength , string fromProviderType , string ownerProviderType )
168
- {
169
- // We MUST check if we are from the same provider (if it's mysql or oracle, we fallback on dbtype
170
- if ( ! String . IsNullOrEmpty ( originalDbType ) && fromProviderType == ownerProviderType )
171
- {
172
- Object ownedDbType = ValidateOwnerDbType ( originalDbType , isUnsigned , isUnicode , maxLength ) ;
173
- return GetMaxLengthFromOwnerDbType ( ownedDbType , maxLength ) ;
174
- }
175
-
176
- // if it's not the same provider, fallback on DbType instead.
177
- return GetMaxLengthFromDbType ( fallbackDbType , maxLength ) ;
178
-
179
- }
180
-
62
+ public abstract Type GetType ( SyncColumn columnDefinition ) ;
181
63
182
64
}
183
65
}
0 commit comments