diff --git a/Directory.Build.props b/Directory.Build.props
index b064bebfcd..3b4c36148d 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,7 +1,7 @@
- 8.0.0-rc-2
+ 8.0.012.0Jeremy D. Miller;Babu Annamalai;Oskar Dudycz;Joona-Pekka Kokkohttps://martendb.io/logo.png
diff --git a/build/build.csproj b/build/build.csproj
index 4d6c8392fd..daff97629c 100644
--- a/build/build.csproj
+++ b/build/build.csproj
@@ -12,7 +12,7 @@
-
+
diff --git a/docs/migration-guide.md b/docs/migration-guide.md
index 3d965830ee..57cc569958 100644
--- a/docs/migration-guide.md
+++ b/docs/migration-guide.md
@@ -1,5 +1,51 @@
# Migration Guide
+## Key Changes in 8.0.0
+
+The V8 release was much smaller than the preceding V7 release, but there are some significant changes to be aware of.
+
+V8 depends on Npgsql 9+.
+
+Marten 8 drops support for .NET 6 and .NET 7. Only .NET 8 and 9 are supported at this moment.
+
+Marten 8 **eliminated almost all synchronous API signatures that result in database calls**. Instead you will need to use
+asynchronous APIs. For example, a call to `IQuerySession.Load(id)`.
+The only exception is the LINQ `ToList()/ToArray()` type operators that result in making database calls with synchronous
+APIs. The Marten team expects that these will probably be removed in Marten 9 and throw `NotSupportedException` exceptions asking
+you to switch to asynchronous methods instead.
+
+The basic shared dependencies underneath Marten and its partner project [Wolverine](https://wolverinefx.net) were consolidated
+for the V8 release into the new, core [JasperFx and JasperFx.Events](https://github.com/jasperfx/jasperfx) libraries. This is
+going to cause some changes to your Marten system when you upgrade:
+
+* JasperFx subsumed what had been "Oakton" for command line parsing. There are temporarily shims for all the public Oakton types and methods, but from
+ this point forward, the core JasperFx library has all the command line parsing and you can pretty well change "Oakton" in your code to "JasperFx"
+* The previous "Marten.CommandLine" Nuget was combined into the core Marten library
+* Some core types like `IEvent` and `StreamAction` moved into the new JasperFx.Events library. Hopefully your IDE can help you change namespace references in your code
+
+The new projection support in JasperFx.Events no longer uses any code generation for any of the projections. The code generation
+for entity types, ancillary document stores, and some internals of the event store still exists unchanged.
+
+The projection base classes changed somewhat for Marten 8:
+
+* The `SingleStreamProjection` now requires 2 generic type arguments for both the projected document type and the identity type of that document (For example, `InvoiceProjection : SingleStreamProjection` in V7 becomes `InvoiceProjection : SingleStreamProjection' in V8). This compromise was made to better support the increasing widespread usage of strong typed identifiers.
+* Both `SingleStreamProjection` and `MultiStreamProjection` have improved options for writing explicit code for projections for more complex scenarios or if you just prefer that over the conventional `Apply` / `Create` method approach
+* `CustomProjection` has been deprecated and marked as `[Obsolete]`! Moreover, it's just a direct subclass of `MultiStreamProjection` now
+* There is also an option in `EventProjection` to use explicit code in place of the its conventional usage, and this is the new recommended approach
+ for projections that do not fit either of the aggregation use cases (`SingleStream/MultiStreamProjection`)
+
+On the bright side, we believe that the "event slicing" usage in Marten 8 is significantly easier to use than it was before.
+
+The existing "Optimized Artifacts Workflow" was completely removed in V8. Instead though, there is a new option shown below:
+
+snippet: sample_AddMartenWithCustomSessionCreation
+
+Note the usage of `CritterStackDefaults()` above. This will allow you to specify separate behavior for `Development` time vs
+`Production` time for frequently variable settings like the generated code loading behavior or the classic `AutoCreate` setting
+for whether or not Marten should do runtime migrations of the database structure. Better yet, these settings are global across
+the entire application so that you no longer have to specify the same variable behavior for [Wolverine](https://wolverinefx.net) when using
+both tools together.
+
## Key Changes in 7.0.0
The V7 release significantly impacted Marten internals and also included support for .NET 8 and and upgrade to Npgsql 8.
@@ -7,13 +53,13 @@ In addition, Marten 7.0 requires at least PostgreSQL 12 because of the dependenc
Marten 7 includes a large overhaul of the LINQ provider support, with highlights including:
-- Very significant improvements to querying through document child collections by being able to opt into
+* Very significant improvements to querying through document child collections by being able to opt into
JSONPath or containment operator querying in many cases. Early reports suggest an order of magnitude improvement in
query times.
-- GIST/GIN indexes should be effective with Marten queries again
-- The `IMethodCallParser` interface changed slightly, and any custom implementations will have to be adjusted
-- Covers significantly more use cases within the LINQ `Where()` filtering
-- `Select()` support was widened to include constructor functions
+* GIST/GIN indexes should be effective with Marten queries again
+* The `IMethodCallParser` interface changed slightly, and any custom implementations will have to be adjusted
+* Covers significantly more use cases within the LINQ `Where()` filtering
+* `Select()` support was widened to include constructor functions
The database connection lifetime logic in `IDocumentSession` or `IQuerySession` was changed from the original Marten 1-6 "sticky" connection behavior. Instead
of Marten trying to keep a database connection open from first usage through any call to `SaveChangesAsync()`, Marten
@@ -37,46 +83,46 @@ The scope of breaking changes is limited, but we highly encourage migrating from
### Guide on migration from v5 to v6:
-- **We Dropped support of .NET Core 3.1 and .NET 5** following the [Official .NET Support Policy](https://dotnet.microsoft.com/en-us/platform/support/policy). That allowed us to benefit fully from recent .NET improvements around asynchronous code, performance etc. Plus made maintenance easier by removing branches of code. If you're using those .NET versions, you need to upgrade to .NET 6 or 7.
-- **Upgraded Npgsql version to 7.** If your project uses an explicitly lower version of Npgsql than 7, you'll need to bump it. We didn't face substantial issues this time, so you might not need to do around it, but you can double-check in the [Npgsql 7 release notes](https://www.npgsql.org/doc/release-notes/7.0.html#breaking-changes) for detailed information about breaking changes on their side.
-- **Generic `OpenSession` store options (`OpenSession(SessionOptions options)` does not track changes by default.** Previously, it was using [identity map](https://martendb.io/documents/sessions.md#identity-map-mechanics). Other overloads of `OpenSession` didn't change the default behavior but were made obsolete. We encourage using explicit session creation and `LightweightSession` by default, as in the next major version, we plan to do the full switch. Read more about the [Unit of Work mechanics](/documents/sessions.md#unit-of-work-mechanics).
-- **Renamed asynchronous session creation to include explicit Serializable name.** `OpenSessionAsync` was misleading, as the intention behind it was to enable proper handling of Postgres' serialized transaction level. Renamed the method to `OpenSerializableSessionAsync` and added explicit methods for session types. Check more in [handling Transaction Isolation Level](/documents/sessions.md#enlisting-in-existing-transactions).
-- **Removed obsolete methods marked as to be removed in the previous versions.**:
- - Removed synchronous'BuildProjectionDaemon`from the`IDocumentStore` method. Use the asynchronous version instead.
- - Removed `Schema` from `IDocumentStore`. Use `Storage` instead.
- - Replaced `GroupEventRange` in `IAggregationRuntime` with `Slicer` reference.
- - Removed unused `UseAppendEventForUpdateLock` setting.
- - Removed the `Searchable` method from `MartenRegistry`. Use `Index` instead.
+* **We Dropped support of .NET Core 3.1 and .NET 5** following the [Official .NET Support Policy](https://dotnet.microsoft.com/en-us/platform/support/policy). That allowed us to benefit fully from recent .NET improvements around asynchronous code, performance etc. Plus made maintenance easier by removing branches of code. If you're using those .NET versions, you need to upgrade to .NET 6 or 7.
+* **Upgraded Npgsql version to 7.** If your project uses an explicitly lower version of Npgsql than 7, you'll need to bump it. We didn't face substantial issues this time, so you might not need to do around it, but you can double-check in the [Npgsql 7 release notes](https://www.npgsql.org/doc/release-notes/7.0.html#breaking-changes) for detailed information about breaking changes on their side.
+* **Generic `OpenSession` store options (`OpenSession(SessionOptions options)` does not track changes by default.** Previously, it was using [identity map](https://martendb.io/documents/sessions.md#identity-map-mechanics). Other overloads of `OpenSession` didn't change the default behavior but were made obsolete. We encourage using explicit session creation and `LightweightSession` by default, as in the next major version, we plan to do the full switch. Read more about the [Unit of Work mechanics](/documents/sessions.md#unit-of-work-mechanics).
+* **Renamed asynchronous session creation to include explicit Serializable name.** `OpenSessionAsync` was misleading, as the intention behind it was to enable proper handling of Postgres' serialized transaction level. Renamed the method to `OpenSerializableSessionAsync` and added explicit methods for session types. Check more in [handling Transaction Isolation Level](/documents/sessions.md#enlisting-in-existing-transactions).
+* **Removed obsolete methods marked as to be removed in the previous versions.**:
+ * Removed synchronous'BuildProjectionDaemon`from the`IDocumentStore` method. Use the asynchronous version instead.
+ * Removed `Schema` from `IDocumentStore`. Use `Storage` instead.
+ * Replaced `GroupEventRange` in `IAggregationRuntime` with `Slicer` reference.
+ * Removed unused `UseAppendEventForUpdateLock` setting.
+ * Removed the `Searchable` method from `MartenRegistry`. Use `Index` instead.
**[ASP.NET JSON streaming `WriteById`](/documents/aspnetcore.md#single-document) is now using correctly custom `onFoundStatus`.** We had the bug and always used the default status. It's enhancement but also technically a breaking change to the behavior. We also added `onFoundStatus` to other methods, so you could specify, e.g. `201 Created` status for creating a new record.
-- **Added [Optimistic concurrency checks](/documents/concurrency.md#optimistic-concurrency) during documents' updates.** Previously, they were only handled when calling the `Store` method; now `Update` uses the same logic.
-- **Base state passed as parameter is returned from `AggregateStreamAsync` instead of null when the stream is empty.** `AggregateStreamAsync` allows passing the default state on which we're applying events. When no events were found, we were always returning null. Now we'll return the passed value. It is helpful when you filter events from a certain version or timestamp. It'll also be useful in the future for archiving scenarios
-- **Ensured events with both `Create` and `Apply` in stream aggregation were handled only once.** When you defined both Create and Apply methods for the specific event, both methods were called for the single event. That wasn't expected behavior. Now they'll be only handled once.
-- **Added missing passing Cancellation Tokens in all async methods in public API.** That ensures that cancellation is handled correctly across the whole codebase. Added the static analysis to ensure we won't miss them in the future.
-- **All the Critter Stack dependencies like `Weasel`, `Lamar`, `JasperFx.Core`, `Oakton`, and `JasperFx.CodeGeneration` were bumped to the latest major versions.** If you use them explicitly, you'll need to align the versions.
+* **Added [Optimistic concurrency checks](/documents/concurrency.md#optimistic-concurrency) during documents' updates.** Previously, they were only handled when calling the `Store` method; now `Update` uses the same logic.
+* **Base state passed as parameter is returned from `AggregateStreamAsync` instead of null when the stream is empty.** `AggregateStreamAsync` allows passing the default state on which we're applying events. When no events were found, we were always returning null. Now we'll return the passed value. It is helpful when you filter events from a certain version or timestamp. It'll also be useful in the future for archiving scenarios
+* **Ensured events with both `Create` and `Apply` in stream aggregation were handled only once.** When you defined both Create and Apply methods for the specific event, both methods were called for the single event. That wasn't expected behavior. Now they'll be only handled once.
+* **Added missing passing Cancellation Tokens in all async methods in public API.** That ensures that cancellation is handled correctly across the whole codebase. Added the static analysis to ensure we won't miss them in the future.
+* **All the Critter Stack dependencies like `Weasel`, `Lamar`, `JasperFx.Core`, `Oakton`, and `JasperFx.CodeGeneration` were bumped to the latest major versions.** If you use them explicitly, you'll need to align the versions.
### Besides that, non-breaking but important changes to upgrade are:
-- **Added explicit `LightweightSession` and `IdentitySession` creation methods to `DocumentStore`**. Previously you could create `DirtyTrackedSession` explicitly. Now you can create all types of sessions explicitly. We recommend using them explicitly instead of the generic `OpenSession` method.
-- **Renamed aggregations into projections and `SelfAggregate` into `Snapshot` and `LiveStreamAggregation`.** The established terms in the Event Sourcing community are Projection and Snapshot. Even though our naming was more precise on the implementation behind the scenes, it could be confusing. We decided to align it with the common naming and be more explicit about the intention. Old methods were marked as obsolete and will be removed in the next major release.
+* **Added explicit `LightweightSession` and `IdentitySession` creation methods to `DocumentStore`**. Previously you could create `DirtyTrackedSession` explicitly. Now you can create all types of sessions explicitly. We recommend using them explicitly instead of the generic `OpenSession` method.
+* **Renamed aggregations into projections and `SelfAggregate` into `Snapshot` and `LiveStreamAggregation`.** The established terms in the Event Sourcing community are Projection and Snapshot. Even though our naming was more precise on the implementation behind the scenes, it could be confusing. We decided to align it with the common naming and be more explicit about the intention. Old methods were marked as obsolete and will be removed in the next major release.
### Other notable new features:
-- **[Added support for reusing Documents in the same async projection batch](/events/projections/event-projections.md#reusing-documents-in-the-same-batch).** By default, Marten does batch to handle multiple events for the projection in one update. When using `EventProjection` and updating data manually using `IDocumentOperations`, this may cause changes made for previous batch items not to be visible. Now you can opt-in for tracking documents by an identity within a batch using the `EnableDocumentTrackingByIdentity` async projection option. Read more in [related docs](/events/projections/event-projections.md#reusing-documents-in-the-same-batch).
-- **Enabled the possibility of applying projections with different Conjoined Tenancy scopes for projections.** Enabled global projection for events with a conjoined tenancy style. Read more in [multi-tenancy documentation](/documents/multi-tenancy.md)
-- **Added automatic retries when schema updates are running in parallel.** Marten locks the schema update using advisory locks. Previously when acquiring lock failed, then schema update also failed. Now it will be retried, which enables easier parallel automated tests and running schema migration during the startup for the containerized environment.
+* **[Added support for reusing Documents in the same async projection batch](/events/projections/event-projections.md#reusing-documents-in-the-same-batch).** By default, Marten does batch to handle multiple events for the projection in one update. When using `EventProjection` and updating data manually using `IDocumentOperations`, this may cause changes made for previous batch items not to be visible. Now you can opt-in for tracking documents by an identity within a batch using the `EnableDocumentTrackingByIdentity` async projection option. Read more in [related docs](/events/projections/event-projections.md#reusing-documents-in-the-same-batch).
+* **Enabled the possibility of applying projections with different Conjoined Tenancy scopes for projections.** Enabled global projection for events with a conjoined tenancy style. Read more in [multi-tenancy documentation](/documents/multi-tenancy.md)
+* **Added automatic retries when schema updates are running in parallel.** Marten locks the schema update using advisory locks. Previously when acquiring lock failed, then schema update also failed. Now it will be retried, which enables easier parallel automated tests and running schema migration during the startup for the containerized environment.
## Key Changes in 5.0.0
V5 was a much smaller release for Marten than V4, and should require much less effort to move from V4 to V5 as it did from V2/3 to V4.
-- The [async daemon](/events/projections/async-daemon) has to be explicitly added with a chained call to `AddAsyncDaemon(mode)`
-- The [Marten integration with .Net bootstrapping](/getting-started) now has the ability to split the Marten configuration for testing overrides or modular configuration
-- `IInitialData` services are executed within IHost bootstrapping. See [Initial Baseline Data](/documents/initial-data).
-- New facility to [apply all detected database changes on application startup](/schema/migrations.html#apply-all-outstanding-changes-upfront).
-- Ability to [register multiple Marten document stores in one .Net IHost](/configuration/hostbuilder.html#working-with-multiple-marten-databases)
-- The ["pre-built code generation" feature](/configuration/prebuilding) has a new, easier to use option in V5
-- New ["Optimized Artifact Workflow"](/configuration/optimized_artifact_workflow) option
-- Some administrative or diagnostic methods that were previously on `IDocumentStore.Advanced` migrated to database specific access [as shown here](/configuration/multitenancy.html#administering-multiple-databases).
+* The [async daemon](/events/projections/async-daemon) has to be explicitly added with a chained call to `AddAsyncDaemon(mode)`
+* The [Marten integration with .Net bootstrapping](/getting-started) now has the ability to split the Marten configuration for testing overrides or modular configuration
+* `IInitialData` services are executed within IHost bootstrapping. See [Initial Baseline Data](/documents/initial-data).
+* New facility to [apply all detected database changes on application startup](/schema/migrations.html#apply-all-outstanding-changes-upfront).
+* Ability to [register multiple Marten document stores in one .Net IHost](/configuration/hostbuilder.html#working-with-multiple-marten-databases)
+* The ["pre-built code generation" feature](/configuration/prebuilding) has a new, easier to use option in V5
+* New ["Optimized Artifact Workflow"](/configuration/optimized_artifact_workflow) option
+* Some administrative or diagnostic methods that were previously on `IDocumentStore.Advanced` migrated to database specific access [as shown here](/configuration/multitenancy.html#administering-multiple-databases).
## Key Changes in 4.0.0
@@ -85,18 +131,18 @@ earlier alphas or RC releases of 4.0 -- you will need to run a [database migrati
Other key, breaking changes:
-- All schema management methods, including assertions on the schema, are now asynchronous. We had to do this for Npgsql connection multiplexing.
-- The [compiled query](/documents/querying/compiled-queries) syntax changed
-- The [event store](/events/) support has quite a few additions
-- [Projections](/events/projections/) in Marten have moved to an all new programming model. Some of it is at least similar, but read the documentation on projection types before moving a Marten application over
-- The [async daemon](/events/projections/async-daemon) was completely rewritten, and is now about to run in application clusters and handle multi-tenancy
-- A few diagnostic methods moved within the API
-- Document types need to be public now, and Marten will alert you if document types are not public
-- The dynamic code in Marten moved to a runtime code generation model. If this is causing you any issues with cold start times or memory usage due to Roslyn misbehaving (this is **not** consistent), there is the new ["generate ahead model"](/configuration/prebuilding) as a workaround.
-- If an application bootstraps Marten through the `IServiceCollection.AddMarten()` extension methods, the default logging in Marten is through the standard
+* All schema management methods, including assertions on the schema, are now asynchronous. We had to do this for Npgsql connection multiplexing.
+* The [compiled query](/documents/querying/compiled-queries) syntax changed
+* The [event store](/events/) support has quite a few additions
+* [Projections](/events/projections/) in Marten have moved to an all new programming model. Some of it is at least similar, but read the documentation on projection types before moving a Marten application over
+* The [async daemon](/events/projections/async-daemon) was completely rewritten, and is now about to run in application clusters and handle multi-tenancy
+* A few diagnostic methods moved within the API
+* Document types need to be public now, and Marten will alert you if document types are not public
+* The dynamic code in Marten moved to a runtime code generation model. If this is causing you any issues with cold start times or memory usage due to Roslyn misbehaving (this is **not** consistent), there is the new ["generate ahead model"](/configuration/prebuilding) as a workaround.
+* If an application bootstraps Marten through the `IServiceCollection.AddMarten()` extension methods, the default logging in Marten is through the standard
`ILogger` of the application
-- In order to support more LINQ query permutations, LINQ queries are temporarily not using the GIN indexable operators on documents that have `GinIndexJsonData()` set. Support for this can be tracked [in this GitHub issue](https://github.com/JasperFx/marten/issues/2051)
-- PLV8 support is disabled by default and moved to a separate package.
+* In order to support more LINQ query permutations, LINQ queries are temporarily not using the GIN indexable operators on documents that have `GinIndexJsonData()` set. Support for this can be tracked [in this GitHub issue](https://github.com/JasperFx/marten/issues/2051)
+* PLV8 support is disabled by default and moved to a separate package.
If an application was setting `StoreOptions.PLV8Enabled = false` to disable PLV8,
that line should be removed as the setting no longer exists. If an application
had `StoreOptions.PLV8Enabled = true` and was using PLV8, you will need to add
@@ -116,19 +162,19 @@ You can also read more in [Jeremy's blog post from](https://jeremydmiller.com/20
## Migration from 2.\*
-- To keep Marten fully rebuilding your schema (so to allow Marten drop tables) set store options to:
+* To keep Marten fully rebuilding your schema (so to allow Marten drop tables) set store options to:
```csharp
AutoCreateSchemaObjects = AutoCreate.All
```
-- To keep [enum fields](/documents/indexing/duplicated-fields) being stored as `varchar` set store options to:
+* To keep [enum fields](/documents/indexing/duplicated-fields) being stored as `varchar` set store options to:
```csharp
DuplicatedFieldEnumStorage = EnumStorage.AsString;
```
-- To keep [duplicated DateTime fields](/documents/indexing/duplicated-fields) being stored as `timestamp with time zone` set store options to:
+* To keep [duplicated DateTime fields](/documents/indexing/duplicated-fields) being stored as `timestamp with time zone` set store options to:
```csharp
DuplicatedFieldUseTimestampWithoutTimeZoneForDateTime = false;
diff --git a/src/DaemonTests/DaemonTests.csproj b/src/DaemonTests/DaemonTests.csproj
index ea98e28dc2..94f7406109 100644
--- a/src/DaemonTests/DaemonTests.csproj
+++ b/src/DaemonTests/DaemonTests.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/src/DocumentDbTests/Internal/Generated/DocumentStorage/RevisionedDocProvider1212098993.cs b/src/DocumentDbTests/Internal/Generated/DocumentStorage/RevisionedDocProvider1212098993.cs
new file mode 100644
index 0000000000..d9e30158cc
--- /dev/null
+++ b/src/DocumentDbTests/Internal/Generated/DocumentStorage/RevisionedDocProvider1212098993.cs
@@ -0,0 +1,1120 @@
+//
+#pragma warning disable
+using DocumentDbTests.Concurrency;
+using Marten.Internal;
+using Marten.Internal.Storage;
+using Marten.Schema;
+using Marten.Schema.Arguments;
+using Npgsql;
+using System;
+using System.Collections.Generic;
+using Weasel.Core;
+using Weasel.Postgresql;
+
+namespace Marten.Generated.DocumentStorage
+{
+ // START: UpsertRevisionedDocOperation1212098993
+ [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
+ public sealed class UpsertRevisionedDocOperation1212098993 : Marten.Internal.Operations.StorageOperation
+ {
+ private readonly DocumentDbTests.Concurrency.RevisionedDoc _document;
+ private readonly System.Guid _id;
+ private readonly System.Collections.Generic.Dictionary _versions;
+ private readonly Marten.Schema.DocumentMapping _mapping;
+
+ public UpsertRevisionedDocOperation1212098993(DocumentDbTests.Concurrency.RevisionedDoc document, System.Guid id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping)
+ {
+ _document = document;
+ _id = id;
+ _versions = versions;
+ _mapping = mapping;
+ }
+
+
+
+ public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions)
+ {
+ if (postprocessRevision(reader, exceptions))
+ {
+ _document.Version = Revision;
+ }
+
+ }
+
+
+ public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token)
+ {
+ if (await postprocessRevisionAsync(reader, exceptions, token))
+ {
+ _document.Version = Revision;
+ }
+
+ }
+
+
+ public override Marten.Internal.Operations.OperationRole Role()
+ {
+ return Marten.Internal.Operations.OperationRole.Upsert;
+ }
+
+
+ public override NpgsqlTypes.NpgsqlDbType DbType()
+ {
+ return NpgsqlTypes.NpgsqlDbType.Uuid;
+ }
+
+
+ public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session)
+ {
+ if (document.Version > 0 && Revision == 1) Revision = document.Version;
+ builder.Append("select numeric_revisioning.mt_upsert_revisioneddoc(");
+ var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document));
+ parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb;
+ // .Net Class Type
+ var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName);
+ parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar;
+ var parameter2 = parameterBuilder.AppendParameter(document.Id);
+ setCurrentRevisionParameter(parameterBuilder);
+ builder.Append(')');
+ }
+
+ }
+
+ // END: UpsertRevisionedDocOperation1212098993
+
+
+ // START: InsertRevisionedDocOperation1212098993
+ [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
+ public sealed class InsertRevisionedDocOperation1212098993 : Marten.Internal.Operations.StorageOperation
+ {
+ private readonly DocumentDbTests.Concurrency.RevisionedDoc _document;
+ private readonly System.Guid _id;
+ private readonly System.Collections.Generic.Dictionary _versions;
+ private readonly Marten.Schema.DocumentMapping _mapping;
+
+ public InsertRevisionedDocOperation1212098993(DocumentDbTests.Concurrency.RevisionedDoc document, System.Guid id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping)
+ {
+ _document = document;
+ _id = id;
+ _versions = versions;
+ _mapping = mapping;
+ }
+
+
+
+ public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions)
+ {
+ _document.Version = Revision;
+ }
+
+
+ public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token)
+ {
+ _document.Version = Revision;
+ return System.Threading.Tasks.Task.CompletedTask;
+ return System.Threading.Tasks.Task.CompletedTask;
+ }
+
+
+ public override Marten.Internal.Operations.OperationRole Role()
+ {
+ return Marten.Internal.Operations.OperationRole.Insert;
+ }
+
+
+ public override NpgsqlTypes.NpgsqlDbType DbType()
+ {
+ return NpgsqlTypes.NpgsqlDbType.Uuid;
+ }
+
+
+ public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session)
+ {
+ if (document.Version > 0 && Revision == 1) Revision = document.Version;
+ builder.Append("select numeric_revisioning.mt_insert_revisioneddoc(");
+ var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document));
+ parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb;
+ // .Net Class Type
+ var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName);
+ parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar;
+ var parameter2 = parameterBuilder.AppendParameter(document.Id);
+ setCurrentRevisionParameter(parameterBuilder);
+ builder.Append(')');
+ }
+
+ }
+
+ // END: InsertRevisionedDocOperation1212098993
+
+
+ // START: UpdateRevisionedDocOperation1212098993
+ [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
+ public sealed class UpdateRevisionedDocOperation1212098993 : Marten.Internal.Operations.StorageOperation
+ {
+ private readonly DocumentDbTests.Concurrency.RevisionedDoc _document;
+ private readonly System.Guid _id;
+ private readonly System.Collections.Generic.Dictionary _versions;
+ private readonly Marten.Schema.DocumentMapping _mapping;
+
+ public UpdateRevisionedDocOperation1212098993(DocumentDbTests.Concurrency.RevisionedDoc document, System.Guid id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping)
+ {
+ _document = document;
+ _id = id;
+ _versions = versions;
+ _mapping = mapping;
+ }
+
+
+
+ public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions)
+ {
+ if (postprocessRevision(reader, exceptions))
+ {
+ _document.Version = Revision;
+ }
+
+ }
+
+
+ public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token)
+ {
+ if (await postprocessRevisionAsync(reader, exceptions, token))
+ {
+ _document.Version = Revision;
+ }
+
+ }
+
+
+ public override Marten.Internal.Operations.OperationRole Role()
+ {
+ return Marten.Internal.Operations.OperationRole.Update;
+ }
+
+
+ public override NpgsqlTypes.NpgsqlDbType DbType()
+ {
+ return NpgsqlTypes.NpgsqlDbType.Uuid;
+ }
+
+
+ public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session)
+ {
+ if (document.Version > 0 && Revision == 1) Revision = document.Version;
+ builder.Append("select numeric_revisioning.mt_update_revisioneddoc(");
+ var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document));
+ parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb;
+ // .Net Class Type
+ var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName);
+ parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar;
+ var parameter2 = parameterBuilder.AppendParameter(document.Id);
+ setCurrentRevisionParameter(parameterBuilder);
+ builder.Append(')');
+ }
+
+ }
+
+ // END: UpdateRevisionedDocOperation1212098993
+
+
+ // START: QueryOnlyRevisionedDocSelector1212098993
+ [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
+ public sealed class QueryOnlyRevisionedDocSelector1212098993 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector
+ {
+ private readonly Marten.Internal.IMartenSession _session;
+ private readonly Marten.Schema.DocumentMapping _mapping;
+
+ public QueryOnlyRevisionedDocSelector1212098993(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping)
+ {
+ _session = session;
+ _mapping = mapping;
+ }
+
+
+
+ public DocumentDbTests.Concurrency.RevisionedDoc Resolve(System.Data.Common.DbDataReader reader)
+ {
+
+ DocumentDbTests.Concurrency.RevisionedDoc document;
+ document = _serializer.FromJson(reader, 0);
+ var version = reader.GetFieldValue(1);
+ document.Version = version;
+ return document;
+ }
+
+
+ public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token)
+ {
+
+ DocumentDbTests.Concurrency.RevisionedDoc document;
+ document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false);
+ var version = await reader.GetFieldValueAsync(1, token);
+ document.Version = version;
+ return document;
+ }
+
+ }
+
+ // END: QueryOnlyRevisionedDocSelector1212098993
+
+
+ // START: LightweightRevisionedDocSelector1212098993
+ [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
+ public sealed class LightweightRevisionedDocSelector1212098993 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector
+ {
+ private readonly Marten.Internal.IMartenSession _session;
+ private readonly Marten.Schema.DocumentMapping _mapping;
+
+ public LightweightRevisionedDocSelector1212098993(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping)
+ {
+ _session = session;
+ _mapping = mapping;
+ }
+
+
+
+ public DocumentDbTests.Concurrency.RevisionedDoc Resolve(System.Data.Common.DbDataReader reader)
+ {
+ var id = reader.GetFieldValue(0);
+
+ DocumentDbTests.Concurrency.RevisionedDoc document;
+ document = _serializer.FromJson(reader, 1);
+ var version = reader.GetFieldValue(2);
+ document.Version = version;
+ _session.MarkAsDocumentLoaded(id, document);
+ return document;
+ }
+
+
+ public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token)
+ {
+ var id = await reader.GetFieldValueAsync(0, token);
+
+ DocumentDbTests.Concurrency.RevisionedDoc document;
+ document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false);
+ var version = await reader.GetFieldValueAsync(2, token);
+ document.Version = version;
+ _session.MarkAsDocumentLoaded(id, document);
+ return document;
+ }
+
+ }
+
+ // END: LightweightRevisionedDocSelector1212098993
+
+
+ // START: IdentityMapRevisionedDocSelector1212098993
+ [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
+ public sealed class IdentityMapRevisionedDocSelector1212098993 : Marten.Internal.CodeGeneration.RevisionedDocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector
+ {
+ private readonly Marten.Internal.IMartenSession _session;
+ private readonly Marten.Schema.DocumentMapping _mapping;
+
+ public IdentityMapRevisionedDocSelector1212098993(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping)
+ {
+ _session = session;
+ _mapping = mapping;
+ }
+
+
+
+ public DocumentDbTests.Concurrency.RevisionedDoc Resolve(System.Data.Common.DbDataReader reader)
+ {
+ var id = reader.GetFieldValue(0);
+ if (_identityMap.TryGetValue(id, out var existing)) return existing;
+
+ DocumentDbTests.Concurrency.RevisionedDoc document;
+ document = _serializer.FromJson(reader, 1);
+ var version = reader.GetFieldValue(2);
+ document.Version = version;
+ _session.MarkAsDocumentLoaded(id, document);
+ _identityMap[id] = document;
+ return document;
+ }
+
+
+ public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token)
+ {
+ var id = await reader.GetFieldValueAsync(0, token);
+ if (_identityMap.TryGetValue(id, out var existing)) return existing;
+
+ DocumentDbTests.Concurrency.RevisionedDoc document;
+ document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false);
+ var version = await reader.GetFieldValueAsync(2, token);
+ document.Version = version;
+ _session.MarkAsDocumentLoaded(id, document);
+ _identityMap[id] = document;
+ return document;
+ }
+
+ }
+
+ // END: IdentityMapRevisionedDocSelector1212098993
+
+
+ // START: DirtyTrackingRevisionedDocSelector1212098993
+ [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
+ public sealed class DirtyTrackingRevisionedDocSelector1212098993 : Marten.Internal.CodeGeneration.RevisionedDocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector
+ {
+ private readonly Marten.Internal.IMartenSession _session;
+ private readonly Marten.Schema.DocumentMapping _mapping;
+
+ public DirtyTrackingRevisionedDocSelector1212098993(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping)
+ {
+ _session = session;
+ _mapping = mapping;
+ }
+
+
+
+ public DocumentDbTests.Concurrency.RevisionedDoc Resolve(System.Data.Common.DbDataReader reader)
+ {
+ var id = reader.GetFieldValue(0);
+ if (_identityMap.TryGetValue(id, out var existing)) return existing;
+
+ DocumentDbTests.Concurrency.RevisionedDoc document;
+ document = _serializer.FromJson(reader, 1);
+ var version = reader.GetFieldValue(2);
+ document.Version = version;
+ _session.MarkAsDocumentLoaded(id, document);
+ _identityMap[id] = document;
+ StoreTracker(_session, document);
+ return document;
+ }
+
+
+ public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token)
+ {
+ var id = await reader.GetFieldValueAsync(0, token);
+ if (_identityMap.TryGetValue(id, out var existing)) return existing;
+
+ DocumentDbTests.Concurrency.RevisionedDoc document;
+ document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false);
+ var version = await reader.GetFieldValueAsync(2, token);
+ document.Version = version;
+ _session.MarkAsDocumentLoaded(id, document);
+ _identityMap[id] = document;
+ StoreTracker(_session, document);
+ return document;
+ }
+
+ }
+
+ // END: DirtyTrackingRevisionedDocSelector1212098993
+
+
+ // START: OverwriteRevisionedDocOperation1212098993
+ [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
+ public sealed class OverwriteRevisionedDocOperation1212098993 : Marten.Internal.Operations.StorageOperation
+ {
+ private readonly DocumentDbTests.Concurrency.RevisionedDoc _document;
+ private readonly System.Guid _id;
+ private readonly System.Collections.Generic.Dictionary _versions;
+ private readonly Marten.Schema.DocumentMapping _mapping;
+
+ public OverwriteRevisionedDocOperation1212098993(DocumentDbTests.Concurrency.RevisionedDoc document, System.Guid id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping)
+ {
+ _document = document;
+ _id = id;
+ _versions = versions;
+ _mapping = mapping;
+ }
+
+
+
+ public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions)
+ {
+ if (postprocessRevision(reader, exceptions))
+ {
+ _document.Version = Revision;
+ }
+
+ }
+
+
+ public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token)
+ {
+ if (await postprocessRevisionAsync(reader, exceptions, token))
+ {
+ _document.Version = Revision;
+ }
+
+ }
+
+
+ public override Marten.Internal.Operations.OperationRole Role()
+ {
+ return Marten.Internal.Operations.OperationRole.Update;
+ }
+
+
+ public override NpgsqlTypes.NpgsqlDbType DbType()
+ {
+ return NpgsqlTypes.NpgsqlDbType.Uuid;
+ }
+
+
+ public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session)
+ {
+ if (document.Version > 0 && Revision == 1) Revision = document.Version;
+ builder.Append("select numeric_revisioning.mt_overwrite_revisioneddoc(");
+ var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document));
+ parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb;
+ // .Net Class Type
+ var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName);
+ parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar;
+ var parameter2 = parameterBuilder.AppendParameter(document.Id);
+ setCurrentRevisionParameter(parameterBuilder);
+ builder.Append(')');
+ }
+
+ }
+
+ // END: OverwriteRevisionedDocOperation1212098993
+
+
+ // START: QueryOnlyRevisionedDocDocumentStorage1212098993
+ [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
+ public sealed class QueryOnlyRevisionedDocDocumentStorage1212098993 : Marten.Internal.Storage.QueryOnlyDocumentStorage
+ {
+ private readonly Marten.Schema.DocumentMapping _document;
+
+ public QueryOnlyRevisionedDocDocumentStorage1212098993(Marten.Schema.DocumentMapping document) : base(document)
+ {
+ _document = document;
+ }
+
+
+
+ public override System.Guid AssignIdentity(DocumentDbTests.Concurrency.RevisionedDoc document, string tenantId, Marten.Storage.IMartenDatabase database)
+ {
+ if (document.Id == Guid.Empty) _setter(document, JasperFx.Core.CombGuidIdGeneration.NewGuid());
+ return document.Id;
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Update(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+ if (session.Concurrency == Marten.Services.ConcurrencyChecks.Disabled)
+ {
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ else
+ {
+
+ return new Marten.Generated.DocumentStorage.UpdateRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Insert(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+
+ return new Marten.Generated.DocumentStorage.InsertRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Upsert(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+ if (session.Concurrency == Marten.Services.ConcurrencyChecks.Disabled)
+ {
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ else
+ {
+
+ return new Marten.Generated.DocumentStorage.UpsertRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Overwrite(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+
+ public override System.Guid Identity(DocumentDbTests.Concurrency.RevisionedDoc document)
+ {
+ return document.Id;
+ }
+
+
+ public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session)
+ {
+ return new Marten.Generated.DocumentStorage.QueryOnlyRevisionedDocSelector1212098993(session, _document);
+ }
+
+
+ public override object RawIdentityValue(System.Guid id)
+ {
+ return id;
+ }
+
+
+ public override Npgsql.NpgsqlParameter BuildManyIdParameter(System.Guid[] ids)
+ {
+ return base.BuildManyIdParameter(ids);
+ }
+
+ }
+
+ // END: QueryOnlyRevisionedDocDocumentStorage1212098993
+
+
+ // START: LightweightRevisionedDocDocumentStorage1212098993
+ [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
+ public sealed class LightweightRevisionedDocDocumentStorage1212098993 : Marten.Internal.Storage.LightweightDocumentStorage
+ {
+ private readonly Marten.Schema.DocumentMapping _document;
+
+ public LightweightRevisionedDocDocumentStorage1212098993(Marten.Schema.DocumentMapping document) : base(document)
+ {
+ _document = document;
+ }
+
+
+
+ public override System.Guid AssignIdentity(DocumentDbTests.Concurrency.RevisionedDoc document, string tenantId, Marten.Storage.IMartenDatabase database)
+ {
+ if (document.Id == Guid.Empty) _setter(document, JasperFx.Core.CombGuidIdGeneration.NewGuid());
+ return document.Id;
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Update(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+ if (session.Concurrency == Marten.Services.ConcurrencyChecks.Disabled)
+ {
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ else
+ {
+
+ return new Marten.Generated.DocumentStorage.UpdateRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Insert(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+
+ return new Marten.Generated.DocumentStorage.InsertRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Upsert(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+ if (session.Concurrency == Marten.Services.ConcurrencyChecks.Disabled)
+ {
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ else
+ {
+
+ return new Marten.Generated.DocumentStorage.UpsertRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Overwrite(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+
+ public override System.Guid Identity(DocumentDbTests.Concurrency.RevisionedDoc document)
+ {
+ return document.Id;
+ }
+
+
+ public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session)
+ {
+ return new Marten.Generated.DocumentStorage.LightweightRevisionedDocSelector1212098993(session, _document);
+ }
+
+
+ public override object RawIdentityValue(System.Guid id)
+ {
+ return id;
+ }
+
+
+ public override Npgsql.NpgsqlParameter BuildManyIdParameter(System.Guid[] ids)
+ {
+ return base.BuildManyIdParameter(ids);
+ }
+
+ }
+
+ // END: LightweightRevisionedDocDocumentStorage1212098993
+
+
+ // START: IdentityMapRevisionedDocDocumentStorage1212098993
+ [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
+ public sealed class IdentityMapRevisionedDocDocumentStorage1212098993 : Marten.Internal.Storage.IdentityMapDocumentStorage
+ {
+ private readonly Marten.Schema.DocumentMapping _document;
+
+ public IdentityMapRevisionedDocDocumentStorage1212098993(Marten.Schema.DocumentMapping document) : base(document)
+ {
+ _document = document;
+ }
+
+
+
+ public override System.Guid AssignIdentity(DocumentDbTests.Concurrency.RevisionedDoc document, string tenantId, Marten.Storage.IMartenDatabase database)
+ {
+ if (document.Id == Guid.Empty) _setter(document, JasperFx.Core.CombGuidIdGeneration.NewGuid());
+ return document.Id;
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Update(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+ if (session.Concurrency == Marten.Services.ConcurrencyChecks.Disabled)
+ {
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ else
+ {
+
+ return new Marten.Generated.DocumentStorage.UpdateRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Insert(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+
+ return new Marten.Generated.DocumentStorage.InsertRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Upsert(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+ if (session.Concurrency == Marten.Services.ConcurrencyChecks.Disabled)
+ {
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ else
+ {
+
+ return new Marten.Generated.DocumentStorage.UpsertRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Overwrite(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+
+ public override System.Guid Identity(DocumentDbTests.Concurrency.RevisionedDoc document)
+ {
+ return document.Id;
+ }
+
+
+ public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session)
+ {
+ return new Marten.Generated.DocumentStorage.IdentityMapRevisionedDocSelector1212098993(session, _document);
+ }
+
+
+ public override object RawIdentityValue(System.Guid id)
+ {
+ return id;
+ }
+
+
+ public override Npgsql.NpgsqlParameter BuildManyIdParameter(System.Guid[] ids)
+ {
+ return base.BuildManyIdParameter(ids);
+ }
+
+ }
+
+ // END: IdentityMapRevisionedDocDocumentStorage1212098993
+
+
+ // START: DirtyTrackingRevisionedDocDocumentStorage1212098993
+ [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
+ public sealed class DirtyTrackingRevisionedDocDocumentStorage1212098993 : Marten.Internal.Storage.DirtyCheckedDocumentStorage
+ {
+ private readonly Marten.Schema.DocumentMapping _document;
+
+ public DirtyTrackingRevisionedDocDocumentStorage1212098993(Marten.Schema.DocumentMapping document) : base(document)
+ {
+ _document = document;
+ }
+
+
+
+ public override System.Guid AssignIdentity(DocumentDbTests.Concurrency.RevisionedDoc document, string tenantId, Marten.Storage.IMartenDatabase database)
+ {
+ if (document.Id == Guid.Empty) _setter(document, JasperFx.Core.CombGuidIdGeneration.NewGuid());
+ return document.Id;
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Update(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+ if (session.Concurrency == Marten.Services.ConcurrencyChecks.Disabled)
+ {
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ else
+ {
+
+ return new Marten.Generated.DocumentStorage.UpdateRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Insert(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+
+ return new Marten.Generated.DocumentStorage.InsertRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Upsert(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+ if (session.Concurrency == Marten.Services.ConcurrencyChecks.Disabled)
+ {
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ else
+ {
+
+ return new Marten.Generated.DocumentStorage.UpsertRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+ }
+
+
+ public override Marten.Internal.Operations.IStorageOperation Overwrite(DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Internal.IMartenSession session, string tenant)
+ {
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+
+ return new Marten.Generated.DocumentStorage.OverwriteRevisionedDocOperation1212098993
+ (
+ document, Identity(document),
+ null,
+ _document
+
+ );
+ }
+
+
+ public override System.Guid Identity(DocumentDbTests.Concurrency.RevisionedDoc document)
+ {
+ return document.Id;
+ }
+
+
+ public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session)
+ {
+ return new Marten.Generated.DocumentStorage.DirtyTrackingRevisionedDocSelector1212098993(session, _document);
+ }
+
+
+ public override object RawIdentityValue(System.Guid id)
+ {
+ return id;
+ }
+
+
+ public override Npgsql.NpgsqlParameter BuildManyIdParameter(System.Guid[] ids)
+ {
+ return base.BuildManyIdParameter(ids);
+ }
+
+ }
+
+ // END: DirtyTrackingRevisionedDocDocumentStorage1212098993
+
+
+ // START: RevisionedDocBulkLoader1212098993
+ [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
+ public sealed class RevisionedDocBulkLoader1212098993 : Marten.Internal.CodeGeneration.BulkLoader
+ {
+ private readonly Marten.Internal.Storage.IDocumentStorage _storage;
+
+ public RevisionedDocBulkLoader1212098993(Marten.Internal.Storage.IDocumentStorage storage) : base(storage)
+ {
+ _storage = storage;
+ }
+
+
+ public const string MAIN_LOADER_SQL = "COPY numeric_revisioning.mt_doc_revisioneddoc(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY";
+
+ public const string TEMP_LOADER_SQL = "COPY mt_doc_revisioneddoc_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY";
+
+ public const string COPY_NEW_DOCUMENTS_SQL = "insert into numeric_revisioning.mt_doc_revisioneddoc (\"id\", \"data\", \"mt_dotnet_type\", \"mt_version\", mt_last_modified) (select mt_doc_revisioneddoc_temp.\"id\", mt_doc_revisioneddoc_temp.\"data\", mt_doc_revisioneddoc_temp.\"mt_dotnet_type\", mt_doc_revisioneddoc_temp.\"mt_version\", transaction_timestamp() from mt_doc_revisioneddoc_temp left join numeric_revisioning.mt_doc_revisioneddoc on mt_doc_revisioneddoc_temp.id = numeric_revisioning.mt_doc_revisioneddoc.id where numeric_revisioning.mt_doc_revisioneddoc.id is null)";
+
+ public const string OVERWRITE_SQL = "update numeric_revisioning.mt_doc_revisioneddoc target SET data = source.data, mt_dotnet_type = source.mt_dotnet_type, mt_version = source.mt_version, mt_last_modified = transaction_timestamp() FROM mt_doc_revisioneddoc_temp source WHERE source.id = target.id";
+
+ public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_revisioneddoc_temp (like numeric_revisioning.mt_doc_revisioneddoc including defaults)";
+
+
+ public override string CreateTempTableForCopying()
+ {
+ return CREATE_TEMP_TABLE_FOR_COPYING_SQL;
+ }
+
+
+ public override string CopyNewDocumentsFromTempTable()
+ {
+ return COPY_NEW_DOCUMENTS_SQL;
+ }
+
+
+ public override string OverwriteDuplicatesFromTempTable()
+ {
+ return OVERWRITE_SQL;
+ }
+
+
+ public override async System.Threading.Tasks.Task LoadRowAsync(Npgsql.NpgsqlBinaryImporter writer, DocumentDbTests.Concurrency.RevisionedDoc document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer, System.Threading.CancellationToken cancellation)
+ {
+ await writer.WriteAsync(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar, cancellation);
+ await writer.WriteAsync(document.Id, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation);
+ await writer.WriteAsync(1, NpgsqlTypes.NpgsqlDbType.Integer, cancellation);
+ await writer.WriteAsync(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb, cancellation);
+ }
+
+
+ public override string MainLoaderSql()
+ {
+ return MAIN_LOADER_SQL;
+ }
+
+
+ public override string TempLoaderSql()
+ {
+ return TEMP_LOADER_SQL;
+ }
+
+ }
+
+ // END: RevisionedDocBulkLoader1212098993
+
+
+ // START: RevisionedDocProvider1212098993
+ [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
+ public sealed class RevisionedDocProvider1212098993 : Marten.Internal.Storage.DocumentProvider
+ {
+ private readonly Marten.Schema.DocumentMapping _mapping;
+
+ public RevisionedDocProvider1212098993(Marten.Schema.DocumentMapping mapping) : base(new RevisionedDocBulkLoader1212098993(new QueryOnlyRevisionedDocDocumentStorage1212098993(mapping)), new QueryOnlyRevisionedDocDocumentStorage1212098993(mapping), new LightweightRevisionedDocDocumentStorage1212098993(mapping), new IdentityMapRevisionedDocDocumentStorage1212098993(mapping), new DirtyTrackingRevisionedDocDocumentStorage1212098993(mapping))
+ {
+ _mapping = mapping;
+ }
+
+
+ }
+
+ // END: RevisionedDocProvider1212098993
+
+
+}
+
diff --git a/src/LinqTestsTypes/LinqTestsTypes.csproj b/src/LinqTestsTypes/LinqTestsTypes.csproj
index 220b11a22b..7de993b562 100644
--- a/src/LinqTestsTypes/LinqTestsTypes.csproj
+++ b/src/LinqTestsTypes/LinqTestsTypes.csproj
@@ -14,6 +14,6 @@
-
+
diff --git a/src/Marten.AspNetCore.Testing/Marten.AspNetCore.Testing.csproj b/src/Marten.AspNetCore.Testing/Marten.AspNetCore.Testing.csproj
index 8dc074ee8b..afb383939c 100644
--- a/src/Marten.AspNetCore.Testing/Marten.AspNetCore.Testing.csproj
+++ b/src/Marten.AspNetCore.Testing/Marten.AspNetCore.Testing.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/src/Marten.Testing/Marten.Testing.csproj b/src/Marten.Testing/Marten.Testing.csproj
index f58559ddc0..28cdd66975 100644
--- a/src/Marten.Testing/Marten.Testing.csproj
+++ b/src/Marten.Testing/Marten.Testing.csproj
@@ -21,7 +21,7 @@
-
+ all
diff --git a/src/Marten/Events/Schema/StreamsTable.cs b/src/Marten/Events/Schema/StreamsTable.cs
index a903d4c771..a1f9561263 100644
--- a/src/Marten/Events/Schema/StreamsTable.cs
+++ b/src/Marten/Events/Schema/StreamsTable.cs
@@ -43,6 +43,9 @@ public StreamsTable(EventGraph events): base(new PostgresqlObjectName(events.Dat
Type = "timestamptz", Writes = false, AllowNulls = false, DefaultExpression = "(now())"
});
+ AddColumn("snapshot", "jsonb");
+ AddColumn("snapshot_version", "integer");
+
AddColumn(new StreamTableColumn("created", x => x.Created)
{
Type = "timestamptz", Writes = false, AllowNulls = false, DefaultExpression = "(now())"
diff --git a/src/Marten/Marten.csproj b/src/Marten/Marten.csproj
index a2cc10f9c8..21e87dfe67 100644
--- a/src/Marten/Marten.csproj
+++ b/src/Marten/Marten.csproj
@@ -32,14 +32,14 @@
-
-
-
+
+
+
-
+
diff --git a/src/StressTests/StressTests.csproj b/src/StressTests/StressTests.csproj
index bd848d68aa..80fc83d1cf 100644
--- a/src/StressTests/StressTests.csproj
+++ b/src/StressTests/StressTests.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/ClassProvider1873568694.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/ClassProvider1873568694.cs
new file mode 100644
index 0000000000..cd2a492a30
--- /dev/null
+++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/ClassProvider1873568694.cs
@@ -0,0 +1,863 @@
+//
+#pragma warning disable
+using Marten.Internal;
+using Marten.Internal.Storage;
+using Marten.Schema;
+using Marten.Schema.Arguments;
+using Npgsql;
+using System.Collections.Generic;
+using ValueTypeTests;
+using Weasel.Core;
+using Weasel.Postgresql;
+
+namespace Marten.Generated.DocumentStorage
+{
+ // START: UpsertClassOperation1873568694
+ [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
+ public sealed class UpsertClassOperation1873568694 : Marten.Internal.Operations.StorageOperation
+ {
+ private readonly ValueTypeTests.Class _document;
+ private readonly ValueTypeTests.ClassId _id;
+ private readonly System.Collections.Generic.Dictionary _versions;
+ private readonly Marten.Schema.DocumentMapping _mapping;
+
+ public UpsertClassOperation1873568694(ValueTypeTests.Class document, ValueTypeTests.ClassId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping)
+ {
+ _document = document;
+ _id = id;
+ _versions = versions;
+ _mapping = mapping;
+ }
+
+
+
+ public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions)
+ {
+ storeVersion();
+ }
+
+
+ public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token)
+ {
+ storeVersion();
+ // Nothing
+ return System.Threading.Tasks.Task.CompletedTask;
+ }
+
+
+ public override Marten.Internal.Operations.OperationRole Role()
+ {
+ return Marten.Internal.Operations.OperationRole.Upsert;
+ }
+
+
+ public override NpgsqlTypes.NpgsqlDbType DbType()
+ {
+ return NpgsqlTypes.NpgsqlDbType.Uuid;
+ }
+
+
+ public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Class document, Marten.Internal.IMartenSession session)
+ {
+ builder.Append("select strong_typed24.mt_upsert_class(");
+ var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document));
+ parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb;
+ // .Net Class Type
+ var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName);
+ parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar;
+
+ if (document.Id != null)
+ {
+ var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value);
+ parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid;
+ }
+
+ else
+ {
+ var parameter2 = parameterBuilder.AppendParameter