Skip to content

Commit

Permalink
Fix GetValue for Nullable enums
Browse files Browse the repository at this point in the history
  • Loading branch information
redbaty committed Oct 16, 2023
1 parent 9a587c7 commit 72eecd1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion PgBulk.EFCore/EntityColumnInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public EntityColumnInformation(string name, bool primaryKey, bool valueGenerated
if (Property == null)
throw new InvalidOperationException("No property is set for this column");

return Property.PropertyType.IsEnum
var truePropertyType = Nullable.GetUnderlyingType(Property.PropertyType) ?? Property.PropertyType;
return truePropertyType.IsEnum
? Convert.ToInt32(Property.GetValue(entity))
: Property.GetValue(entity);
}
Expand Down
2 changes: 1 addition & 1 deletion PgBulk.EFCore/PgBulk.EFCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
<PackageProjectUrl>https://github.com/redbaty/PgBulk</PackageProjectUrl>
<PackageVersion>1.1.13</PackageVersion>
<PackageVersion>1.1.14</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 72eecd1

Please sign in to comment.