diff --git a/ACUtils.SqlDb/ACUtils.SqlDb.csproj b/ACUtils.SqlDb/ACUtils.SqlDb.csproj index fe97431..29ecb3e 100644 --- a/ACUtils.SqlDb/ACUtils.SqlDb.csproj +++ b/ACUtils.SqlDb/ACUtils.SqlDb.csproj @@ -5,7 +5,7 @@ Andrea Cattaneo true false - 1.0.0.146 + 1.0.0.147 1.0.0.146 Utility per interrogazione database MSSQL it diff --git a/ACUtils.SqlDb/SqlDb.cs b/ACUtils.SqlDb/SqlDb.cs index 5456d58..af37332 100644 --- a/ACUtils.SqlDb/SqlDb.cs +++ b/ACUtils.SqlDb/SqlDb.cs @@ -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) diff --git a/ACUtils.SqlDb/SqlDb_QueryDataSet.cs b/ACUtils.SqlDb/SqlDb_QueryDataSet.cs index 005d832..1ee655a 100644 --- a/ACUtils.SqlDb/SqlDb_QueryDataSet.cs +++ b/ACUtils.SqlDb/SqlDb_QueryDataSet.cs @@ -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; diff --git a/ACUtils.SqlDb/SqlDb_QueryMany.cs b/ACUtils.SqlDb/SqlDb_QueryMany.cs index 3f8b7ee..f3d73a0 100644 --- a/ACUtils.SqlDb/SqlDb_QueryMany.cs +++ b/ACUtils.SqlDb/SqlDb_QueryMany.cs @@ -14,7 +14,7 @@ public static class SqlDb_QueryMany return QueryMany(connection, queryString, new KeyValuePair[0]); } #endregion - #region static with simple params + #region static with simple params public static List QueryMany(SqlConnection connection, string queryString, params KeyValuePair[] queryParams) where T : ACUtils.DBModel, new() { return _return(SqlDb_QueryDataTable.QueryDataTable(connection, queryString, queryParams));