-
Notifications
You must be signed in to change notification settings - Fork 345
-
Hello,
I'm currently developing a tool called SQLWrapper, which aims to automatically generate a C# wrapper from SQL queries:
SQLWrapper NuGet Package
SQLWrapper GitHub Repository
Presently, the SQL wrapper does not include a command timeout feature.
I understand that there are scenarios where modifying the command timeout, especially for large queries, is necessary to increase query execution time.
I see two potential solutions to address this:
- Adding Command Timeout as a Parameter in Each SQL Wrapper Method:
public static async Task<SelectResult?> Select(MySqlConnection conn, MySqlTransaction transaction, long productId, int timeout) { using MySqlCommand sqlCmd = new MySqlCommand { CommandTimeout = timeout,
- Defining a Connection String with Command Timeout=XXX
-
I'm seeking your feedback to determine which solution would be preferable: Solution 1 or 2?
-
Additionally, if you have the opportunity to test my SQLWrapper tool, I would greatly appreciate any feedback you can provide.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
I would lean towards option (1), Adding Command Timeout as a Parameter in Each SQL Wrapper Method.
The reason for this choice is that this often needs to be customised on a per-query basis and a single value (from the connection string) for all queries isn't always appropriate.
I would probably write it as int? timeout = null
and only set DbCommand.CommandTimeout
if the user supplied a value. If none is supplied (i.e., the parameter isn't specified) then the default timeout would be used.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1