11using QueryDB . Resources ;
22using System . Collections . Generic ;
3+ using System . Threading . Tasks ;
34
45namespace 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