Skip to content

Commit

Permalink
Resolve null to DbNull value in parameter. (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
chullybun authored Jun 28, 2023
1 parent 84f502f commit 0db9c0a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Represents the **NuGet** versions.

## v3.1.1
- *Fixed:* The `DatabaseParameterCollection.AddParameter` now explicitly sets the `DbParameter.Value` to `DbNull.Value` where the value passed in is `null`.

## v3.1.0
- *Enhancement:* Added `Hosting.ServiceBase` class for a self-orchestrated service to execute for a specified `MaxIterations`; provides an alternative to using a `HostedService`. Useful for the likes of timer trigger Azure Functions for eample.
- *Enhancement:* Added `EventOutboxService` as an alternative to `EventOutboxHostedService`; related to (and leverages) above to achieve same outcome.
Expand Down
2 changes: 1 addition & 1 deletion Common.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>3.1.0</Version>
<Version>3.1.1</Version>
<LangVersion>preview</LangVersion>
<Authors>Avanade</Authors>
<Company>Avanade</Company>
Expand Down
4 changes: 2 additions & 2 deletions src/CoreEx.Database/DatabaseParameterCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public DbParameter AddParameter(string name, object? value, ParameterDirection d
{
var p = Database.Provider.CreateParameter() ?? throw new InvalidOperationException($"The {nameof(DbProviderFactory)}.{nameof(DbProviderFactory.CreateParameter)} returned a null.");
p.ParameterName = ParameterizeName(name);
p.Value = value;
p.Value = value ?? DBNull.Value;
p.Direction = direction;

_parameters.Add(p);
Expand All @@ -75,7 +75,7 @@ public DbParameter AddParameter(string name, object? value, DbType dbType, Param
var p = Database.Provider.CreateParameter() ?? throw new InvalidOperationException($"The {nameof(DbProviderFactory)}.{nameof(DbProviderFactory.CreateParameter)} returned a null.");
p.ParameterName = ParameterizeName(name);
p.DbType = dbType;
p.Value = value;
p.Value = value ?? DBNull.Value;
p.Direction = direction;

_parameters.Add(p);
Expand Down

0 comments on commit 0db9c0a

Please sign in to comment.