Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SQLWrapper: Should Command Timeout be Implemented as a Parameter or in the Connection String? #1471

Unanswered
daikoz asked this question in Q&A
Discussion options

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:

  1. 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,
  1. 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.

You must be logged in to vote

Replies: 1 comment

Comment options

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.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /