You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using an identity map, it will throw when records that have been previously loaded are modified & stored, as the record will not meet the reference equality check.
ProjectAsync<MyEntityEdited>(async(edited,operations)=>{varentities=await operations.LoadManyAsync<MyEntity>(created.IdList);varupdatedEntities= entities.Select(x => x with{SomeId= edited.Id }).ToArray(); operations.Store(updatedEntities);});
System.InvalidOperationException
Document 'MyEntity' with same Id already added to the session.
at Marten.Internal.Storage.IdentityMapDocumentStorage`2.store(IMartenSession session, T document, TId& id)
at Marten.Internal.Storage.IdentityMapDocumentStorage`2.Store(IMartenSession session, T document)
at Marten.Internal.Sessions.DocumentSessionBase.storeEntity[T](T entity, IDocumentStorage`1 storage)
at Marten.Internal.Sessions.DocumentSessionBase.store[T](IEnumerable`1 entities)
at Marten.Internal.Sessions.DocumentSessionBase.Store[T](T[] entities)
The text was updated successfully, but these errors were encountered:
Hawxy
changed the title
EventProjection uses IdentityMap by default
EventProjection's DocumentOperations IdentityMap throws on document store
Jan 24, 2023
Hawxy
added a commit
to Hawxy/marten
that referenced
this issue
Jan 26, 2023
Hawxy
changed the title
EventProjection's DocumentOperations IdentityMap throws on document store
IdentityMap throws when records are loaded & modified.
Jan 26, 2023
@jeremydmiller I've fixed this locally by checking if the type implements IEquatable<T> and skipping the equality check if it does. Can push it up if you're fine with that as a solution.
When using an identity map, it will throw when records that have been previously loaded are modified & stored, as the record will not meet the reference equality check.
Relevant part of the identity map:
marten/src/Marten/Internal/Storage/IdentityMapDocumentStorage.cs
Line 53 in 6459822
The text was updated successfully, but these errors were encountered: