From e9207e0c8f0c8543d74e6dd7f0ef7dc7f0029346 Mon Sep 17 00:00:00 2001 From: Armus Daube Date: Sun, 15 Dec 2024 15:57:58 -0500 Subject: [PATCH] Fixed bug where FetchForWriting (the overload accepting an expected version) would throw an InvalidCastException when the aggregate is inline and UseIdentityMapForAggregates = true. --- src/Marten/Events/Fetching/FetchInlinedPlan.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Marten/Events/Fetching/FetchInlinedPlan.cs b/src/Marten/Events/Fetching/FetchInlinedPlan.cs index bc14811752..13bd26ccf1 100644 --- a/src/Marten/Events/Fetching/FetchInlinedPlan.cs +++ b/src/Marten/Events/Fetching/FetchInlinedPlan.cs @@ -100,7 +100,7 @@ public async Task> FetchForWriting(DocumentSessionBase sessio IDocumentStorage storage = null; if (session.Options.Events.UseIdentityMapForAggregates) { - storage = (IDocumentStorage)session.Options.Providers.StorageFor(); + storage = session.Options.ResolveCorrectedDocumentStorage(DocumentTracking.IdentityOnly); // Opt into the identity map mechanics for this aggregate type just in case // you're using a lightweight session session.UseIdentityMapFor();