Skip to content

Commit

Permalink
update setting value to clr type.
Browse files Browse the repository at this point in the history
  • Loading branch information
saturn72 committed Jul 2, 2023
1 parent 3887cb4 commit be0ba35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion EfAudit/AuditSaveChangesInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ private object ToClrInstance(EntityEntry entry)
return entry.CurrentValues.Clone().ToObject();

var value = Activator.CreateInstance(clrType);
entry.CurrentValues.SetValues(value);
foreach (var p in entry.Properties)
{
var fi = p.Metadata.FieldInfo;
if (fi == default)
continue;
fi.SetValue(value, p.CurrentValue ?? default);
}
return value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion EfAudit/EfAudit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageId>EfAudit</PackageId>
<PackageVersion>1.0.20</PackageVersion>
<PackageVersion>1.0.21</PackageVersion>
<Authors>roi@saturn72.com</Authors>
<Company>saturn technologies</Company>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down

0 comments on commit be0ba35

Please sign in to comment.