Skip to content

Commit 4a231ac

Browse files
Merge pull request #10 from abhinavminhas/dev
Nuget Package Creation - v1.2.0
2 parents 5c847fe + a9805ab commit 4a231ac

File tree

17 files changed

+4899
-275
lines changed

17 files changed

+4899
-275
lines changed

.github/workflows/publish-nuget-Package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Publish Nuget Package
22

33
env:
4-
NUGET_PACKAGE_NAME_VERSION: "QueryDB.1.1.0.nupkg"
4+
NUGET_PACKAGE_NAME_VERSION: "QueryDB.1.2.0.nupkg"
55

66
on:
77
workflow_dispatch:

CHANGELOG.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,23 @@ All notable changes to this project documented here.
33

44
## [Released]
55

6+
## [1.2.0](https://www.nuget.org/packages/QueryDB/1.2.0) - 2025-03-04
7+
### Added
8+
- Asynchronous operations
9+
- `FetchDataAsync()`
10+
- `ExecuteScalarAsync()`
11+
- `ExecuteCommandAsync()`
12+
- `ExecuteTransactionAsync()`
13+
### Changed
14+
- Execute transaction to return transaction outcome and exception details in case of failure instead of logging into console.
15+
16+
## [1.1.0](https://www.nuget.org/packages/QueryDB/1.1.0) - 2025-02-20
17+
### Added
18+
- Execute scalar queries (returning a single value).
19+
620
## [1.0.0](https://www.nuget.org/packages/QueryDB/1.0.0) - 2025-02-18
721
### Added
822
- QueryDB framework for simplified querying and executing transactions across multiple database systems.
923
- Retrieve data from database.
1024
- Execute database commands.
11-
- Execute transactions while maintaining atomicity.
12-
13-
## [1.1.0](https://www.nuget.org/packages/QueryDB/1.1.0) - 2025-02-20
14-
### Added
15-
- Execute scalar queries (returning a single value).
25+
- Execute transactions while maintaining atomicity.

QueryDB.Core.Tests/MSSQLTests.cs

Lines changed: 869 additions & 27 deletions
Large diffs are not rendered by default.

QueryDB.Core.Tests/MySQLTests.cs

Lines changed: 841 additions & 30 deletions
Large diffs are not rendered by default.

QueryDB.Core.Tests/OracleTests.cs

Lines changed: 848 additions & 26 deletions
Large diffs are not rendered by default.

QueryDB.Core.Tests/PostgreSQLTests.cs

Lines changed: 835 additions & 30 deletions
Large diffs are not rendered by default.

QueryDB.Core.Tests/QueryDBTests.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
22
using System.Collections.Generic;
3+
using System.Threading.Tasks;
34

45
namespace QueryDB.Core.Tests
56
{
@@ -23,17 +24,14 @@ public void ExecuteCommand_UnknownDB_ReturnsNegativeOne()
2324

2425
[TestMethod]
2526
[TestCategory(DB_TESTS), TestCategory(UNKNOW_DB_TESTS)]
26-
public void ExecuteTransaction_UnknownDB_ReturnsFalse()
27+
public async Task ExecuteCommandAsync_UnknownDB_ReturnsNegativeOne()
2728
{
28-
var sqlStatements = new List<string>
29-
{
30-
"DELETE FROM users"
31-
};
29+
string sqlStatement = "DELETE FROM users";
3230

3331
var dbContext = new DBContext((DB)999, "some_invalid_connection_string");
34-
var result = dbContext.ExecuteTransaction(sqlStatements);
32+
var result = await dbContext.ExecuteCommandAsync(sqlStatement);
3533

36-
Assert.IsFalse(result);
34+
Assert.AreEqual(-1, result);
3735
}
3836

3937
#endregion

QueryDB/DBContext.cs

Lines changed: 320 additions & 23 deletions
Large diffs are not rendered by default.

QueryDB/IDBContext.cs

Lines changed: 87 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using QueryDB.Resources;
22
using System.Collections.Generic;
3+
using System.Threading.Tasks;
34

45
namespace QueryDB
56
{
@@ -9,52 +10,120 @@ namespace QueryDB
910
interface IDBContext
1011
{
1112
/// <summary>
12-
/// Retrieves records for 'Select' queries from the database.
13+
/// Executes and retrieves records for 'Select' queries from the database.
1314
/// </summary>
1415
/// <param name="selectSql">'Select' query.</param>
15-
/// <param name="upperCaseKeys">Boolean parameter to return dictionary keys in uppercase. Default - 'false'.</param>
16-
/// <returns>List of data Dictionary with column names as keys holding values into a list for multiple rows of data.</returns>
16+
/// <param name="upperCaseKeys">Boolean parameter to return dictionary keys in uppercase. Default - <c>false</c>.</param>
17+
/// <returns>List of <see cref="DataDictionary"/> with column names as keys holding values into a list for multiple rows of data.</returns>
1718
List<DataDictionary> FetchData(string selectSql, bool upperCaseKeys = false);
1819

1920
/// <summary>
20-
/// Retrieves records for 'Select' queries from the database.
21+
/// Executes and retrieves records for 'Select' queries from the database.
2122
/// </summary>
2223
/// <typeparam name="T">Object entity to return data mapped into.</typeparam>
2324
/// <param name="selectSql">'Select' query.</param>
24-
/// <param name="strict">Enables fetch data only for object <T> properties existing in database query result. Default - 'false'.</param>
25-
/// <returns>List of data rows mapped into object entity into a list for multiple rows of data.</returns>
25+
/// <param name="strict">Enables fetch data only for object type <typeparamref name="T"/> properties existing in database query result. Default - <c>false</c>.</param>
26+
/// <returns>List of data rows mapped into object of type <typeparamref name="T"/>.</returns>
2627
List<T> FetchData<T>(string selectSql, bool strict = false) where T : new();
2728

2829
/// <summary>
29-
/// Executes a SQL query and returns the result as a string.
30+
/// Asynchronously executes and retrieves records for 'Select' queries from the database.
3031
/// </summary>
31-
/// <param name="sqlStatement">The SQL query to execute.</param>
32-
/// <returns>A string representing the result of the query. If the result is DBNull, an empty string is returned.</returns>
32+
/// <param name="selectSql">'Select' query.</param>
33+
/// <param name="upperCaseKeys">Boolean parameter to return dictionary keys in uppercase. Default - <c>false</c>.</param>
34+
/// <returns>List of <see cref="DataDictionary"/> with column names as keys holding values into a list for multiple rows of data.</returns>
35+
Task<List<DataDictionary>> FetchDataAsync(string selectSql, bool upperCaseKeys = false);
36+
37+
/// <summary>
38+
/// Asynchronously executes and retrieves records for 'Select' queries from the database.
39+
/// </summary>
40+
/// <typeparam name="T">Object entity to return data mapped into.</typeparam>
41+
/// <param name="selectSql">'Select' query.</param>
42+
/// <param name="strict">Enables fetch data only for object type <typeparamref name="T"/> properties existing in database query result. Default - <c>false</c>.</param>
43+
Task<List<T>> FetchDataAsync<T>(string selectSql, bool strict = false) where T : new();
44+
45+
/// <summary>
46+
/// Executes the provided SQL statement and returns the first column of the first row in the result set.
47+
/// If the result is DBNull, an empty string is returned.
48+
/// </summary>
49+
/// <param name="sqlStatement">The SQL statement to execute. It should be a query that returns a single value.</param>
50+
/// <returns>
51+
/// A <see cref="string"/> representing the value of the first column of the first row in the result set,
52+
/// or an empty string if the result is DBNull.
53+
/// </returns>
3354
string ExecuteScalar(string sqlStatement);
3455

3556
/// <summary>
36-
/// Executes a SQL query and returns the result as the specified type.
57+
/// Executes the provided SQL statement and returns the first column of the first row in the result set,
58+
/// converted to the specified type <typeparamref name="T"/>. If the result is DBNull, the default value of <typeparamref name="T"/> is returned.
3759
/// </summary>
3860
/// <typeparam name="T">The type to which the result should be converted.</typeparam>
39-
/// <param name="sqlStatement">The SQL query to execute.</param>
40-
/// <returns>The result of the query, converted to the specified type. If the result is DBNull, the default value for the type is returned.</returns>
61+
/// <param name="sqlStatement">The SQL statement to execute. It should be a query that returns a single value.</param>
62+
/// <returns>
63+
/// The value of the first column of the first row in the result set, converted to type <typeparamref name="T"/>,
64+
/// or the default value of <typeparamref name="T"/> if the result is DBNull.
65+
/// </returns>
4166
T ExecuteScalar<T>(string sqlStatement);
4267

4368
/// <summary>
44-
/// Executes SQL commands.
69+
/// Asynchronously executes the provided SQL statement and returns the first column of the first row in the result set.
70+
/// If the result is DBNull, an empty string is returned.
4571
/// </summary>
46-
/// <param name="sqlStatement">SQL statement as command.</param>
47-
/// <returns>The number of rows affected.</returns>
72+
/// <param name="sqlStatement">The SQL statement to execute. It should be a query that returns a single value.</param>
73+
/// <returns>
74+
/// A <see cref="string"/> representing the value of the first column of the first row in the result set,
75+
/// or an empty string if the result is DBNull.
76+
/// </returns>
77+
Task<string> ExecuteScalarAsync(string sqlStatement);
78+
79+
/// <summary>
80+
/// Asynchronously executes the provided SQL statement and returns the first column of the first row in the result set,
81+
/// converted to the specified type <typeparamref name="T"/>. If the result is DBNull, the default value of <typeparamref name="T"/> is returned.
82+
/// </summary>
83+
/// <typeparam name="T">The type to which the result should be converted.</typeparam>
84+
/// <param name="sqlStatement">The SQL statement to execute. It should be a query that returns a single value.</param>
85+
/// <returns>
86+
/// The value of the first column of the first row in the result set, converted to type <typeparamref name="T"/>,
87+
/// or the default value of <typeparamref name="T"/> if the result is DBNull.
88+
/// </returns>
89+
Task<T> ExecuteScalarAsync<T>(string sqlStatement);
90+
91+
/// <summary>
92+
/// Executes a SQL statement that does not return a result set.
93+
/// </summary>
94+
/// <param name="sqlStatement">SQL statement to execute.</param>
95+
/// <returns>The number of rows affected by the execution of the SQL statement.</returns>
4896
int ExecuteCommand(string sqlStatement);
4997

98+
/// <summary>
99+
/// Asynchronously executes a SQL statement that does not return a result set.
100+
/// </summary>
101+
/// <param name="sqlStatement">SQL statement to execute.</param>
102+
/// <returns>The number of rows affected by the execution of the SQL statement.</returns>
103+
Task<int> ExecuteCommandAsync(string sqlStatement);
104+
50105
/// <summary>
51106
/// Executes multiple SQL statements within a transaction, ensuring that all statements are executed together.
52107
/// </summary>
53108
/// <param name="sqlStatements">A list of SQL statements to execute.</param>
54109
/// <returns>
55-
/// Returns <c>true</c> if all statements are executed successfully and the transaction is committed;
56-
/// <c>false</c> if any statement fails and the transaction is rolled back.
110+
/// A <see cref="Result"/> object indicating the outcome of the transaction.
111+
/// The <see cref="Result.Success"/> property is <c>true</c> if the transaction is committed successfully;
112+
/// otherwise, <c>false</c> if an error occurs and the transaction is rolled back.
113+
/// If an error occurs, the <see cref="Result.Exception"/> property contains the exception details.
114+
/// </returns>
115+
Result ExecuteTransaction(List<string> sqlStatements);
116+
117+
/// <summary>
118+
/// Asynchronously executes multiple SQL statements within a transaction, ensuring that all statements are executed together.
119+
/// </summary>
120+
/// <param name="sqlStatements">A list of SQL statements to execute.</param>
121+
/// <returns>
122+
/// A <see cref="Result"/> object indicating the outcome of the transaction.
123+
/// The <see cref="Result.Success"/> property is <c>true</c> if the transaction is committed successfully;
124+
/// otherwise, <c>false</c> if an error occurs and the transaction is rolled back.
125+
/// If an error occurs, the <see cref="Result.Exception"/> property contains the exception details.
57126
/// </returns>
58-
bool ExecuteTransaction(List<string> sqlStatements);
127+
Task<Result> ExecuteTransactionAsync(List<string> sqlStatements);
59128
}
60129
}

0 commit comments

Comments
 (0)