diff --git a/Havit.Data.Entity6/DbContext.cs b/Havit.Data.Entity6/DbContext.cs index ebedabdc7..834b1782c 100644 --- a/Havit.Data.Entity6/DbContext.cs +++ b/Havit.Data.Entity6/DbContext.cs @@ -61,7 +61,7 @@ protected DbContext() : base("name=DefaultConnectionString") /// } /// /// -#pragma warning disable S3253 // "base()" constructor calls should not be explicitly made // JK: Chci ho zde pro přehlednost! +#pragma warning disable S3253 // "base()" constructor calls should not be explicitly made // JK: Chci ho zde pro přehlednost! protected DbContext(DbContextDefaultDatabase dbContextDefaultDatabase) : base() #pragma warning restore S3253 // "base()" constructor calls should not be explicitly made { @@ -319,6 +319,29 @@ public TResult ExecuteWithoutAutoDetectChanges(Func action) } } + /// + /// Provede akci s Configuration.UseDatabaseNullSemantics nastaveným na true, přičemž je poté Configuration.UseDatabaseNullSemantics nastaven na původní hodnotu. + /// + public TResult ExecuteWithDatabaseNullSemantics(Func action) + { + if (!Configuration.UseDatabaseNullSemantics) + { + try + { + Configuration.UseDatabaseNullSemantics = true; + return action(); + } + finally + { + Configuration.UseDatabaseNullSemantics = false; + } + } + else + { + return action(); + } + } + /// /// Pouze pro existenci přetížení konstruktoru DbContextu, díky kterému se použije bezparametrický konstruktor předka. /// diff --git a/Havit.Data.Entity6/Havit.Data.Entity6.csproj b/Havit.Data.Entity6/Havit.Data.Entity6.csproj index 8a2da4d59..8080a82d6 100644 --- a/Havit.Data.Entity6/Havit.Data.Entity6.csproj +++ b/Havit.Data.Entity6/Havit.Data.Entity6.csproj @@ -10,7 +10,7 @@ - 2.0.1 + 2.0.2 HAVIT .NET Framework Extensions - Entity Framework 6 Extensions diff --git a/Havit.Data.Entity6/IDbContext.cs b/Havit.Data.Entity6/IDbContext.cs index cf31fc0be..56b0c5b42 100644 --- a/Havit.Data.Entity6/IDbContext.cs +++ b/Havit.Data.Entity6/IDbContext.cs @@ -95,5 +95,10 @@ void SetEntityCollectionLoaded(TEntity entity, string propertyName, boo /// Provede akci s AutoDetectChangesEnabled nastaveným na false, přičemž je poté AutoDetectChangesEnabled nastaven na původní hodnotu. /// TResult ExecuteWithoutAutoDetectChanges(Func action); + + /// + /// Provede akci s Configuration.UseDatabaseNullSemantics nastaveným na true, přičemž je poté Configuration.UseDatabaseNullSemantics nastaven na původní hodnotu. + /// + TResult ExecuteWithDatabaseNullSemantics(Func action); } }