Skip to content

Commit

Permalink
Ensure entity type is registered for EntityEntry
Browse files Browse the repository at this point in the history
Fixes #261
  • Loading branch information
Turnerj committed Oct 31, 2021
1 parent bd0cd9b commit a163b11
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/MongoFramework/Infrastructure/EntityEntry.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using MongoDB.Bson;
using MongoFramework.Infrastructure.Mapping;

namespace MongoFramework.Infrastructure
{
Expand Down Expand Up @@ -33,6 +34,9 @@ public EntityEntry(object entity, EntityEntryState state)
Entity = entity;
EntityType = entity.GetType();

// Ensure the entity type is registered before we potentially serialize the entity to a BSON document
EntityMapping.TryRegisterType(EntityType, out _);

if (state == EntityEntryState.NoChanges)
{
OriginalValues = Entity.ToBsonDocument();
Expand Down

0 comments on commit a163b11

Please sign in to comment.