Skip to content

Commit 7e65118

Browse files
committed
removed IDataContract Interface dependency
1 parent 78c2425 commit 7e65118

6 files changed

Lines changed: 30 additions & 52 deletions

File tree

src/DatabaseManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public DatabaseManager(T databaseProvider)
2828
/// <param name="query">The SQL query to execute.</param>
2929
/// <param name="tableName">The name of the table associated with the query.</param>
3030
/// <returns>A list of results of type <typeparamref name="TItem"/>.</returns>
31-
public List<TItem> ExecuteQuery<TItem>(string query, string tableName) where TItem : IDataContract
31+
public List<TItem> ExecuteQuery<TItem>(string query, string tableName)
3232
{
3333
List<TItem> result = new List<TItem>();
3434

src/Extensions/DataRowExtensions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ public static class DataRowExtensions
1414
/// <param name="row">The DataRow from which to retrieve the value.</param>
1515
/// <param name="columnName">The name of the column.</param>
1616
/// <returns>The value of the specified column, converted to the specified type.</returns>
17-
/// <remarks>
18-
/// This extension method is intended for use with classes that inherit from <see cref="IDataContract"/>.
19-
/// </remarks>
2017
public static T GetValue<T>(this DataRow row, string columnName)
2118
{
2219
// Check if the DataRow is null

src/Helper/QueryHelper.cs

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,29 @@ public class QueryHelper
1212
/// <summary>
1313
/// Gets the table name of a specified type, considering the TableNameAttribute if present.
1414
/// </summary>
15-
/// <typeparam name="T">The type for which to get the table name. Must implement <see cref="IDataContract"/>.</typeparam>
15+
/// <typeparam name="T">The type for which to get the table name.</typeparam>
1616
/// <returns>The table name.</returns>
17-
public string GetTableName<T>() where T : IDataContract
17+
public string GetTableName<T>()
1818
{
1919
return CacheManager.GetTableName(typeof(T));
2020
}
2121

2222
/// <summary>
2323
/// Gets the table schema of a specified type, considering the TableSchemaAttribute if present.
2424
/// </summary>
25-
/// <typeparam name="T">The type for which to get the table schema. Must implement <see cref="IDataContract"/>.</typeparam>
25+
/// <typeparam name="T">The type for which to get the table schema.</typeparam>
2626
/// <returns>The table schema name or null if not specified.</returns>
27-
public string? GetTableSchema<T>() where T : IDataContract
27+
public string? GetTableSchema<T>()
2828
{
2929
return CacheManager.GetTableSchema(typeof(T));
3030
}
3131

3232
/// <summary>
3333
/// Gets whether the type specifies to generate an INSERT query with ID, considering the GenerateInsertWithIDAttribute if present.
3434
/// </summary>
35-
/// <typeparam name="T">The type for which to determine the generation of INSERT query with ID. Must implement <see cref="IDataContract"/>.</typeparam>
35+
/// <typeparam name="T">The type for which to determine the generation of INSERT query with ID.</typeparam>
3636
/// <returns>True if the INSERT query should include ID, otherwise false.</returns>
37-
public bool GetInsertWithID<T>() where T : IDataContract
37+
public bool GetInsertWithID<T>()
3838
{
3939
return CacheManager.GetInsertWithID(typeof(T));
4040
}
@@ -44,80 +44,73 @@ public bool GetInsertWithID<T>() where T : IDataContract
4444
/// during insert query generation, considering the GenerateInsertWithIDAttribute if present.
4545
/// </summary>
4646
/// <typeparam name="T">The type for which to determine the inclusion of identity insert statements.
47-
/// Must implement <see cref="IDataContract"/>.</typeparam>
47+
///</typeparam>
4848
/// <returns><c>true</c> if identity insert statements should be included; otherwise, <c>false</c>.</returns>
49-
public bool GetIncludeIdentityInsert<T>() where T : IDataContract
49+
public bool GetIncludeIdentityInsert<T>()
5050
{
5151
return CacheManager.GetIncludeIdentityInsert(typeof(T));
5252
}
5353

5454
/// <summary>
5555
/// Gets the names of properties marked as key columns for a specified type.
5656
/// </summary>
57-
/// <typeparam name="T">The type for which to get the key columns. Must implement <see cref="IDataContract"/>.</typeparam>
57+
/// <typeparam name="T">The type for which to get the key columns.</typeparam>
5858
/// <returns>A list of key column names.</returns>
59-
/// <seealso cref="IDataContract"/>
60-
public List<string> GetKeyColumns<T>() where T : IDataContract
59+
public List<string> GetKeyColumns<T>()
6160
{
6261
return CacheManager.GetKeyColumns(typeof(T));
6362
}
6463

6564
/// <summary>
6665
/// Gets the names of properties marked as excluded properties for a specified type.
6766
/// </summary>
68-
/// <typeparam name="T">The type for which to get the excluded properties. Must implement <see cref="IDataContract"/>.</typeparam>
67+
/// <typeparam name="T">The type for which to get the excluded properties.</typeparam>
6968
/// <returns>A list of excluded property names.</returns>
70-
/// <seealso cref="IDataContract"/>
71-
public List<string> GetExcludedColumns<T>() where T : IDataContract
69+
public List<string> GetExcludedColumns<T>()
7270
{
7371
return CacheManager.GetExcludedColumns(typeof(T));
7472
}
7573

7674
/// <summary>
7775
/// Gets the names of all properties for a specified type.
7876
/// </summary>
79-
/// <typeparam name="T">The type for which to get all properties. Must implement <see cref="IDataContract"/>.</typeparam>
77+
/// <typeparam name="T">The type for which to get all properties.</typeparam>
8078
/// <returns>A list of all property names.</returns>
81-
/// <seealso cref="IDataContract"/>
82-
public List<string> GetAllColumns<T>() where T : IDataContract
79+
public List<string> GetAllColumns<T>()
8380
{
8481
return CacheManager.GetAllColumns(typeof(T));
8582
}
8683

8784
/// <summary>
8885
/// Retrieves a list of identity columns for a specified data contract type <typeparamref name="T"/>.
8986
/// </summary>
90-
/// <typeparam name="T">The type implementing the IDataContract interface.</typeparam>
9187
/// <returns>A list containing the names of identity columns for the specified data contract type <typeparamref name="T"/>.</returns>
9288
/// <remarks>
9389
/// This method uses reflection to analyze the properties of the specified type <typeparamref name="T"/> and retrieves properties marked with a [Key] attribute, indicating identity columns.
9490
/// </remarks>
95-
/// <seealso cref="IDataContract"/>
96-
public List<string> GetIdentityColumns<T>() where T : IDataContract
91+
public List<string> GetIdentityColumns<T>()
9792
{
9893
return CacheManager.GetIdentityColumns(typeof(T));
9994
}
10095

10196
/// <summary>
10297
/// Retrieves an array of <see cref="PropertyInfo"/> objects representing the properties that are used for data comparison
103-
/// in objects of type <typeparamref name="T"/>. These properties are determined based on the implementation of the
104-
/// <see cref="IDataContract"/> interface.
98+
/// in objects of type <typeparamref name="T"/>.
10599
/// </summary>
106100
/// <typeparam name="T">The type of objects for which to retrieve comparable properties.</typeparam>
107101
/// <returns>An array of <see cref="PropertyInfo"/> objects representing the comparable properties of type <typeparamref name="T"/>.</returns>
108-
public PropertyInfo[] GetComparableProperties<T>() where T: IDataContract
102+
public PropertyInfo[] GetComparableProperties<T>()
109103
{
110104
return CacheManager.GetComparableProperties(typeof(T));
111105
}
112106

113107
/// <summary>
114108
/// Retrieves an array of <see cref="PropertyInfo"/> objects representing the properties that are used as key properties
115-
/// for uniquely identifying objects of type <typeparamref name="T"/>. These key properties are determined based on the
116-
/// implementation of the <see cref="IDataContract"/> interface.
109+
/// for uniquely identifying objects of type <typeparamref name="T"/>.
117110
/// </summary>
118111
/// <typeparam name="T">The type of objects for which to retrieve key properties.</typeparam>
119112
/// <returns>An array of <see cref="PropertyInfo"/> objects representing the key properties of type <typeparamref name="T"/>.</returns>
120-
public PropertyInfo[] GetKeyProperties<T>() where T : IDataContract
113+
public PropertyInfo[] GetKeyProperties<T>()
121114
{
122115
return CacheManager.GetKeyProperties(typeof(T));
123116
}

src/Interface/IDataContract.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/Interface/IQueryGenerator.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public interface IQueryGenerator : IDisposable
1313
/// <param name="ListOfColumns">The list of columns to be selected.</param>
1414
/// <param name="schemaName">The schema name of the database table.</param>
1515
/// <returns>A string representing the generated SELECT query.</returns>
16-
string GenerateSelectQuery<T>(string tableName, List<string> ListOfColumns, string schemaName) where T : IDataContract;
16+
string GenerateSelectQuery<T>(string tableName, List<string> ListOfColumns, string schemaName);
1717

1818
/// <summary>
1919
/// Generates an UPDATE query for updating data in a database table.
@@ -24,7 +24,7 @@ public interface IQueryGenerator : IDisposable
2424
/// <param name="excludedColumns">The list of columns to be excluded from the update.</param>
2525
/// <param name="editedProperties">A dictionary representing the properties and their new values to be updated.</param>
2626
/// <returns>A string representing the generated UPDATE query.</returns>
27-
string GenerateUpdateQuery<T>(T DataContract, List<string> keyColumns, List<string> excludedColumns, (string propName, object propValue)[] editedProperties) where T : IDataContract;
27+
string GenerateUpdateQuery<T>(T DataContract, List<string> keyColumns, List<string> excludedColumns, (string propName, object propValue)[] editedProperties);
2828

2929
/// <summary>
3030
/// Generates a DELETE query for deleting data from a database table.
@@ -33,7 +33,7 @@ public interface IQueryGenerator : IDisposable
3333
/// <param name="entity">The entity representing the data to be deleted.</param>
3434
/// <param name="keyColumns">The list of key columns used for deletion.</param>
3535
/// <returns>A string representing the generated DELETE query.</returns>
36-
string GenerateDeleteQuery<T>(T entity, List<string> keyColumns) where T : IDataContract;
36+
string GenerateDeleteQuery<T>(T entity, List<string> keyColumns);
3737

3838
/// <summary>
3939
/// Generates an INSERT query for inserting data into a database table.
@@ -43,7 +43,7 @@ public interface IQueryGenerator : IDisposable
4343
/// <param name="keyColumns">The list of key columns used for insertion.</param>
4444
/// <param name="excludedColumns">The list of columns to be excluded from the insertion.</param>
4545
/// <returns>A string representing the generated INSERT query.</returns>
46-
string GenerateInsertQuery<T>(T entity, List<string> keyColumns, List<string> excludedColumns) where T : IDataContract;
46+
string GenerateInsertQuery<T>(T entity, List<string> keyColumns, List<string> excludedColumns);
4747

4848
/// <summary>
4949
/// Generates a SQL comment.
@@ -59,7 +59,7 @@ public interface IQueryGenerator : IDisposable
5959
/// <param name="entity">The entity for which the condition is generated.</param>
6060
/// <param name="keyColumns">The list of key columns used to create the condition.</param>
6161
/// <returns>A string representing the generated condition for a SQL WHERE clause.</returns>
62-
List<string> GetCondition<T>(T entity, List<string> keyColumns) where T : IDataContract;
62+
List<string> GetCondition<T>(T entity, List<string> keyColumns);
6363

6464
/// <summary>
6565
/// Escapes special characters in the input to make it SQL-safe.

src/QueryGenerationManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ public QueryGenerationManager(IQueryGenerator querryGenerator)
2424

2525
#region Public Methods
2626
/// <inheritdoc />
27-
public string GenerateSelectQuery<T>(string tableName, List<string> listOfColumns, string schemaName) where T : IDataContract
27+
public string GenerateSelectQuery<T>(string tableName, List<string> listOfColumns, string schemaName)
2828
{
2929
return _querryGenerator.GenerateSelectQuery<T>(tableName, listOfColumns, schemaName);
3030
}
3131

3232
/// <inheritdoc />
33-
public string GenerateUpdateQuery<T>(T DataContract, List<string> keyColumns, List<string> excludedColumns, (string propName, object propValue)[] editedProperties) where T : IDataContract
33+
public string GenerateUpdateQuery<T>(T DataContract, List<string> keyColumns, List<string> excludedColumns, (string propName, object propValue)[] editedProperties)
3434
{
3535
return _querryGenerator.GenerateUpdateQuery<T>(DataContract, keyColumns, excludedColumns, editedProperties);
3636
}
3737

3838
/// <inheritdoc />
39-
public string GenerateDeleteQuery<T>(T entity, List<string> keyColumns) where T : IDataContract
39+
public string GenerateDeleteQuery<T>(T entity, List<string> keyColumns)
4040
{
4141
return _querryGenerator.GenerateDeleteQuery<T>(entity, keyColumns);
4242
}
4343

4444
/// <inheritdoc />
45-
public string GenerateInsertQuery<T>(T entity, List<string> keyColumns, List<string> excludedColumns) where T : IDataContract
45+
public string GenerateInsertQuery<T>(T entity, List<string> keyColumns, List<string> excludedColumns)
4646
{
4747
return _querryGenerator.GenerateInsertQuery<T>(entity, keyColumns, excludedColumns);
4848
}
@@ -54,7 +54,7 @@ public string GenerateComment(string comment)
5454
}
5555

5656
/// <inheritdoc />
57-
public List<string> GetCondition<T>(T entity, List<string> keyColumns) where T : IDataContract
57+
public List<string> GetCondition<T>(T entity, List<string> keyColumns)
5858
{
5959
return _querryGenerator.GetCondition<T>(entity, keyColumns);
6060
}

0 commit comments

Comments
 (0)