Skip to content

Commit

Permalink
SqlDb - EnforceConstraints param
Browse files Browse the repository at this point in the history
  • Loading branch information
cattaneoinfoesse committed Dec 1, 2022
1 parent e7a9a40 commit d135dc8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ACUtils.SqlDb/ACUtils.SqlDb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Authors>Andrea Cattaneo</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Version>1.0.0.146</Version>
<Version>1.0.0.147</Version>
<PackageVersion>1.0.0.146</PackageVersion>
<Description>Utility per interrogazione database MSSQL</Description>
<NeutralLanguage>it</NeutralLanguage>
Expand Down
20 changes: 6 additions & 14 deletions ACUtils.SqlDb/SqlDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,14 @@ public class SqlDb : IDisposable
public ILogger logger { get; protected set; }
private TransactionScope scope;

private static MissingSchemaAction? missingSchemaAction;

private bool _persistentConnection = false;
private SqlConnection _connection = null;
public static MissingSchemaAction MissingSchemaAction
{
get
{
if (missingSchemaAction == null)
{
missingSchemaAction = MissingSchemaAction.AddWithKey;
}
return missingSchemaAction.GetValueOrDefault();
}
set => missingSchemaAction = value;
}

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

private static bool enforceConstraints = true;
public static bool EnforceConstraints { get => enforceConstraints; set => enforceConstraints = value; }

#region constructor
public SqlDb(string connectionString, ILogger logger, bool persistentConnection = false)
Expand Down
1 change: 1 addition & 0 deletions ACUtils.SqlDb/SqlDb_QueryDataSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ private static DataSet _return(SqlCommand selectCommand)
using (SqlDataAdapter adapter = new SqlDataAdapter(selectCommand))
{
DataSet ds = new DataSet();
ds.EnforceConstraints = SqlDb.EnforceConstraints;
adapter.MissingSchemaAction = SqlDb.MissingSchemaAction;
adapter.Fill(ds);
return ds;
Expand Down
2 changes: 1 addition & 1 deletion ACUtils.SqlDb/SqlDb_QueryMany.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static class SqlDb_QueryMany
return QueryMany<T>(connection, queryString, new KeyValuePair<string, object>[0]);
}
#endregion
#region static with simple params
#region static with simple params
public static List<T> QueryMany<T>(SqlConnection connection, string queryString, params KeyValuePair<string, object>[] queryParams) where T : ACUtils.DBModel<T>, new()
{
return _return<T>(SqlDb_QueryDataTable.QueryDataTable(connection, queryString, queryParams));
Expand Down

0 comments on commit d135dc8

Please sign in to comment.