@@ -11,32 +11,14 @@ namespace DbSyncKit.DB.Helper
1111 /// </summary>
1212 public class QueryHelper
1313 {
14- /// <summary>
15- /// Replaces a specified placeholder in a StringBuilder with the provided replacement string.
16- /// </summary>
17- /// <param name="stringBuilder">The StringBuilder to modify.</param>
18- /// <param name="placeholder">The placeholder to replace.</param>
19- /// <param name="replacement">The string to replace the placeholder.</param>
20- public void ReplacePlaceholder ( ref StringBuilder stringBuilder , string placeholder , string replacement )
21- {
22- // Use Regex to replace all occurrences of the placeholder
23- string pattern = Regex . Escape ( placeholder ) ;
24- stringBuilder . Replace ( pattern , replacement ) ;
25- }
26-
2714 /// <summary>
2815 /// Gets the table name of a specified type, considering the TableNameAttribute if present.
2916 /// </summary>
3017 /// <typeparam name="T">The type for which to get the table name. Must implement <see cref="IDataContractComparer"/>.</typeparam>
3118 /// <returns>The table name.</returns>
3219 public string GetTableName < T > ( ) where T : IDataContractComparer
3320 {
34- TableNameAttribute ? tableNameAttribute = ( TableNameAttribute ? ) Attribute . GetCustomAttribute ( typeof ( T ) , typeof ( TableNameAttribute ) ) ;
35-
36- if ( tableNameAttribute != null )
37- return tableNameAttribute . TableName ;
38-
39- return typeof ( T ) . Name ;
21+ return CacheManager . GetTableName ( typeof ( T ) ) ;
4022 }
4123
4224 /// <summary>
@@ -46,12 +28,7 @@ public string GetTableName<T>() where T : IDataContractComparer
4628 /// <returns>The table schema name or null if not specified.</returns>
4729 public string ? GetTableSchema < T > ( ) where T : IDataContractComparer
4830 {
49- TableSchemaAttribute ? tableSchemaAttribute = ( TableSchemaAttribute ? ) Attribute . GetCustomAttribute ( typeof ( T ) , typeof ( TableSchemaAttribute ) ) ;
50-
51- if ( tableSchemaAttribute != null )
52- return tableSchemaAttribute . SchemaName ;
53-
54- return null ;
31+ return CacheManager . GetTableSchema ( typeof ( T ) ) ;
5532 }
5633
5734 /// <summary>
@@ -61,12 +38,7 @@ public string GetTableName<T>() where T : IDataContractComparer
6138 /// <returns>True if the INSERT query should include ID, otherwise false.</returns>
6239 public bool GetInsertWithID < T > ( ) where T : IDataContractComparer
6340 {
64- GenerateInsertWithIDAttribute ? tableSchemaAttribute = ( GenerateInsertWithIDAttribute ? ) Attribute . GetCustomAttribute ( typeof ( T ) , typeof ( GenerateInsertWithIDAttribute ) ) ;
65-
66- if ( tableSchemaAttribute != null )
67- return tableSchemaAttribute . GenerateWithID ;
68-
69- return false ;
41+ return CacheManager . GetInsertWithID ( typeof ( T ) ) ;
7042 }
7143
7244 /// <summary>
@@ -78,12 +50,7 @@ public bool GetInsertWithID<T>() where T : IDataContractComparer
7850 /// <returns><c>true</c> if identity insert statements should be included; otherwise, <c>false</c>.</returns>
7951 public bool GetIncludeIdentityInsert < T > ( ) where T : IDataContractComparer
8052 {
81- GenerateInsertWithIDAttribute ? attribute = ( GenerateInsertWithIDAttribute ? ) Attribute . GetCustomAttribute ( typeof ( T ) , typeof ( GenerateInsertWithIDAttribute ) ) ;
82-
83- if ( attribute != null )
84- return attribute . IncludeIdentityInsert ;
85-
86- return false ;
53+ return CacheManager . GetIncludeIdentityInsert ( typeof ( T ) ) ;
8754 }
8855
8956 /// <summary>
@@ -94,7 +61,7 @@ public bool GetIncludeIdentityInsert<T>() where T : IDataContractComparer
9461 /// <seealso cref="IDataContractComparer"/>
9562 public List < string > GetKeyColumns < T > ( ) where T : IDataContractComparer
9663 {
97- return TypePropertyCacheManager . GetKeyColumns ( typeof ( T ) ) ;
64+ return CacheManager . GetKeyColumns ( typeof ( T ) ) ;
9865 }
9966
10067 /// <summary>
@@ -105,7 +72,7 @@ public List<string> GetKeyColumns<T>() where T : IDataContractComparer
10572 /// <seealso cref="IDataContractComparer"/>
10673 public List < string > GetExcludedProperties < T > ( ) where T : IDataContractComparer
10774 {
108- return TypePropertyCacheManager . GetExcludedProperties ( typeof ( T ) ) ;
75+ return CacheManager . GetExcludedProperties ( typeof ( T ) ) ;
10976 }
11077
11178 /// <summary>
@@ -116,7 +83,7 @@ public List<string> GetExcludedProperties<T>() where T : IDataContractComparer
11683 /// <seealso cref="IDataContractComparer"/>
11784 public List < string > GetAllColumns < T > ( ) where T : IDataContractComparer
11885 {
119- return TypePropertyCacheManager . GetAllColumns ( typeof ( T ) ) ;
86+ return CacheManager . GetAllColumns ( typeof ( T ) ) ;
12087 }
12188
12289 /// <summary>
@@ -130,7 +97,7 @@ public List<string> GetAllColumns<T>() where T : IDataContractComparer
13097 /// <seealso cref="IDataContractComparer"/>
13198 public List < string > GetIdentityColumns < T > ( ) where T : IDataContractComparer
13299 {
133- return TypePropertyCacheManager . GetIdentityColumns ( typeof ( T ) ) ;
100+ return CacheManager . GetIdentityColumns ( typeof ( T ) ) ;
134101 }
135102
136103 }
0 commit comments