Skip to content

Commit

Permalink
SqlDb v1.0.0.153 - command timeout parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
acattaneo-bitagora committed Feb 24, 2023
1 parent aa134b9 commit 8fc35b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ACUtils.SqlDb/ACUtils.SqlDb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<Authors>Andrea Cattaneo</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Version>1.0.0.152</Version>
<PackageVersion>1.0.0.152</PackageVersion>
<Version>1.0.0.153</Version>
<PackageVersion>1.0.0.153</PackageVersion>
<Description>Utility per interrogazione database MSSQL</Description>
<NeutralLanguage>it</NeutralLanguage>
<IncludeSymbols>true</IncludeSymbols>
Expand Down
10 changes: 8 additions & 2 deletions ACUtils.SqlDb/SqlDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class SqlDb : IDisposable

private static MissingSchemaAction missingSchemaAction = MissingSchemaAction.AddWithKey;
public static MissingSchemaAction MissingSchemaAction { get => missingSchemaAction; set => missingSchemaAction = value; }
public static int? CommandTimeout;

private static bool enforceConstraints = true;
public static bool EnforceConstraints { get => enforceConstraints; set => enforceConstraints = value; }
Expand Down Expand Up @@ -53,7 +54,12 @@ public SqlDb(string connectionString, bool persistentConnection = false)
#region generateCommand
internal static SqlCommand generateCommand(SqlConnection connection, string queryString)
{
return new SqlCommand(queryString, connection);
var command = new SqlCommand(queryString, connection);
if (CommandTimeout.HasValue)
{
command.CommandTimeout = CommandTimeout.Value;
}
return command;
}

internal static SqlCommand generateCommand(SqlConnection connection, string queryString, KeyValuePair<string, object>[] queryParams)
Expand Down Expand Up @@ -406,7 +412,7 @@ public static T GetColVal<T>(DataRow dataRow, string columnName)
switch (val.GetType().Name)
{
case "DBNull":
return default(T);
return default;
}
switch (typeof(T).Name)
{
Expand Down

0 comments on commit 8fc35b3

Please sign in to comment.