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.0 12.0 Jeremy D. Miller;Babu Annamalai;Oskar Dudycz;Joona-Pekka Kokko https://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(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertClassOperation1873568694 + + + // START: InsertClassOperation1873568694 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class InsertClassOperation1873568694 : 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 InsertClassOperation1873568694(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.Insert; + } + + + 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_insert_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(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertClassOperation1873568694 + + + // START: UpdateClassOperation1873568694 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpdateClassOperation1873568694 : 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 UpdateClassOperation1873568694(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(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + 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, ValueTypeTests.Class document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_update_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(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateClassOperation1873568694 + + + // START: QueryOnlyClassSelector1873568694 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyClassSelector1873568694 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyClassSelector1873568694(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Class Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.Class document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.Class document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyClassSelector1873568694 + + + // START: LightweightClassSelector1873568694 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightClassSelector1873568694 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightClassSelector1873568694(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Class Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.ClassId.From(reader.GetFieldValue(0)); + + ValueTypeTests.Class document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.ClassId.From(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.Class document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightClassSelector1873568694 + + + // START: IdentityMapClassSelector1873568694 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapClassSelector1873568694 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapClassSelector1873568694(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Class Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.ClassId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Class document; + document = _serializer.FromJson(reader, 1); + _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 = ValueTypeTests.ClassId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Class document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapClassSelector1873568694 + + + // START: DirtyTrackingClassSelector1873568694 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingClassSelector1873568694 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingClassSelector1873568694(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Class Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.ClassId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Class document; + document = _serializer.FromJson(reader, 1); + _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 = ValueTypeTests.ClassId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Class document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingClassSelector1873568694 + + + // START: QueryOnlyClassDocumentStorage1873568694 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyClassDocumentStorage1873568694 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyClassDocumentStorage1873568694(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.ClassId AssignIdentity(ValueTypeTests.Class document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.ClassId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.ClassId Identity(ValueTypeTests.Class document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyClassSelector1873568694(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.ClassId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.ClassId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyClassDocumentStorage1873568694 + + + // START: LightweightClassDocumentStorage1873568694 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightClassDocumentStorage1873568694 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightClassDocumentStorage1873568694(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.ClassId AssignIdentity(ValueTypeTests.Class document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.ClassId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.ClassId Identity(ValueTypeTests.Class document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightClassSelector1873568694(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.ClassId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.ClassId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightClassDocumentStorage1873568694 + + + // START: IdentityMapClassDocumentStorage1873568694 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapClassDocumentStorage1873568694 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapClassDocumentStorage1873568694(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.ClassId AssignIdentity(ValueTypeTests.Class document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.ClassId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.ClassId Identity(ValueTypeTests.Class document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapClassSelector1873568694(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.ClassId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.ClassId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapClassDocumentStorage1873568694 + + + // START: DirtyTrackingClassDocumentStorage1873568694 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingClassDocumentStorage1873568694 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingClassDocumentStorage1873568694(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.ClassId AssignIdentity(ValueTypeTests.Class document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.ClassId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.ClassId Identity(ValueTypeTests.Class document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingClassSelector1873568694(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.ClassId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.ClassId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingClassDocumentStorage1873568694 + + + // START: ClassBulkLoader1873568694 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class ClassBulkLoader1873568694 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public ClassBulkLoader1873568694(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed24.mt_doc_class(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_class_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed24.mt_doc_class (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_class_temp.\"id\", mt_doc_class_temp.\"data\", mt_doc_class_temp.\"mt_version\", mt_doc_class_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_class_temp left join strong_typed24.mt_doc_class on mt_doc_class_temp.id = strong_typed24.mt_doc_class.id where strong_typed24.mt_doc_class.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed24.mt_doc_class target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_class_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_class_temp (like strong_typed24.mt_doc_class 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, ValueTypeTests.Class 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.Value.Value, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(JasperFx.Core.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, 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: ClassBulkLoader1873568694 + + + // START: ClassProvider1873568694 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class ClassProvider1873568694 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public ClassProvider1873568694(Marten.Schema.DocumentMapping mapping) : base(new ClassBulkLoader1873568694(new QueryOnlyClassDocumentStorage1873568694(mapping)), new QueryOnlyClassDocumentStorage1873568694(mapping), new LightweightClassDocumentStorage1873568694(mapping), new IdentityMapClassDocumentStorage1873568694(mapping), new DirtyTrackingClassDocumentStorage1873568694(mapping)) + { + _mapping = mapping; + } + + + } + + // END: ClassProvider1873568694 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/GradeProvider907442297.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/GradeProvider907442297.cs new file mode 100644 index 0000000000..424d82899d --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/GradeProvider907442297.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: UpsertGradeOperation907442297 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpsertGradeOperation907442297 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Grade _document; + private readonly ValueTypeTests.GradeId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertGradeOperation907442297(ValueTypeTests.Grade document, ValueTypeTests.GradeId 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.Grade document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_upsert_grade("); + 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(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertGradeOperation907442297 + + + // START: InsertGradeOperation907442297 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class InsertGradeOperation907442297 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Grade _document; + private readonly ValueTypeTests.GradeId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertGradeOperation907442297(ValueTypeTests.Grade document, ValueTypeTests.GradeId 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.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Grade document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_insert_grade("); + 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(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertGradeOperation907442297 + + + // START: UpdateGradeOperation907442297 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpdateGradeOperation907442297 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Grade _document; + private readonly ValueTypeTests.GradeId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateGradeOperation907442297(ValueTypeTests.Grade document, ValueTypeTests.GradeId 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(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + 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, ValueTypeTests.Grade document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_update_grade("); + 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(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateGradeOperation907442297 + + + // START: QueryOnlyGradeSelector907442297 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyGradeSelector907442297 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyGradeSelector907442297(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Grade Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.Grade document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.Grade document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyGradeSelector907442297 + + + // START: LightweightGradeSelector907442297 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightGradeSelector907442297 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightGradeSelector907442297(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Grade Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.GradeId.From(reader.GetFieldValue(0)); + + ValueTypeTests.Grade document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.GradeId.From(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.Grade document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightGradeSelector907442297 + + + // START: IdentityMapGradeSelector907442297 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapGradeSelector907442297 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapGradeSelector907442297(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Grade Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.GradeId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Grade document; + document = _serializer.FromJson(reader, 1); + _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 = ValueTypeTests.GradeId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Grade document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapGradeSelector907442297 + + + // START: DirtyTrackingGradeSelector907442297 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingGradeSelector907442297 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingGradeSelector907442297(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Grade Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.GradeId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Grade document; + document = _serializer.FromJson(reader, 1); + _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 = ValueTypeTests.GradeId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Grade document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingGradeSelector907442297 + + + // START: QueryOnlyGradeDocumentStorage907442297 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyGradeDocumentStorage907442297 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyGradeDocumentStorage907442297(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.GradeId AssignIdentity(ValueTypeTests.Grade document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.GradeId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.GradeId Identity(ValueTypeTests.Grade document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyGradeSelector907442297(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.GradeId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.GradeId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyGradeDocumentStorage907442297 + + + // START: LightweightGradeDocumentStorage907442297 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightGradeDocumentStorage907442297 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightGradeDocumentStorage907442297(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.GradeId AssignIdentity(ValueTypeTests.Grade document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.GradeId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.GradeId Identity(ValueTypeTests.Grade document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightGradeSelector907442297(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.GradeId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.GradeId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightGradeDocumentStorage907442297 + + + // START: IdentityMapGradeDocumentStorage907442297 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapGradeDocumentStorage907442297 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapGradeDocumentStorage907442297(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.GradeId AssignIdentity(ValueTypeTests.Grade document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.GradeId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.GradeId Identity(ValueTypeTests.Grade document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapGradeSelector907442297(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.GradeId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.GradeId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapGradeDocumentStorage907442297 + + + // START: DirtyTrackingGradeDocumentStorage907442297 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingGradeDocumentStorage907442297 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingGradeDocumentStorage907442297(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.GradeId AssignIdentity(ValueTypeTests.Grade document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.GradeId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.GradeId Identity(ValueTypeTests.Grade document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingGradeSelector907442297(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.GradeId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.GradeId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingGradeDocumentStorage907442297 + + + // START: GradeBulkLoader907442297 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class GradeBulkLoader907442297 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public GradeBulkLoader907442297(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed24.mt_doc_grade(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_grade_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed24.mt_doc_grade (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_grade_temp.\"id\", mt_doc_grade_temp.\"data\", mt_doc_grade_temp.\"mt_version\", mt_doc_grade_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_grade_temp left join strong_typed24.mt_doc_grade on mt_doc_grade_temp.id = strong_typed24.mt_doc_grade.id where strong_typed24.mt_doc_grade.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed24.mt_doc_grade target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_grade_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_grade_temp (like strong_typed24.mt_doc_grade 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, ValueTypeTests.Grade 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.Value.Value, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(JasperFx.Core.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, 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: GradeBulkLoader907442297 + + + // START: GradeProvider907442297 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class GradeProvider907442297 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public GradeProvider907442297(Marten.Schema.DocumentMapping mapping) : base(new GradeBulkLoader907442297(new QueryOnlyGradeDocumentStorage907442297(mapping)), new QueryOnlyGradeDocumentStorage907442297(mapping), new LightweightGradeDocumentStorage907442297(mapping), new IdentityMapGradeDocumentStorage907442297(mapping), new DirtyTrackingGradeDocumentStorage907442297(mapping)) + { + _mapping = mapping; + } + + + } + + // END: GradeProvider907442297 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/Invoice2Provider479877131.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Invoice2Provider479877131.cs new file mode 100644 index 0000000000..9c620804c5 --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Invoice2Provider479877131.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.StrongTypedId; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertInvoice2Operation479877131 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpsertInvoice2Operation479877131 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Invoice2 _document; + private readonly ValueTypeTests.StrongTypedId.Invoice2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertInvoice2Operation479877131(ValueTypeTests.StrongTypedId.Invoice2 document, ValueTypeTests.StrongTypedId.Invoice2Id 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.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed1.mt_upsert_invoice2("); + 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(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertInvoice2Operation479877131 + + + // START: InsertInvoice2Operation479877131 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class InsertInvoice2Operation479877131 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Invoice2 _document; + private readonly ValueTypeTests.StrongTypedId.Invoice2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertInvoice2Operation479877131(ValueTypeTests.StrongTypedId.Invoice2 document, ValueTypeTests.StrongTypedId.Invoice2Id 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.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed1.mt_insert_invoice2("); + 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(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertInvoice2Operation479877131 + + + // START: UpdateInvoice2Operation479877131 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpdateInvoice2Operation479877131 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Invoice2 _document; + private readonly ValueTypeTests.StrongTypedId.Invoice2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateInvoice2Operation479877131(ValueTypeTests.StrongTypedId.Invoice2 document, ValueTypeTests.StrongTypedId.Invoice2Id 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(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + 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, ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed1.mt_update_invoice2("); + 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(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateInvoice2Operation479877131 + + + // START: QueryOnlyInvoice2Selector479877131 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyInvoice2Selector479877131 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyInvoice2Selector479877131(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice2 Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyInvoice2Selector479877131 + + + // START: LightweightInvoice2Selector479877131 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightInvoice2Selector479877131 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightInvoice2Selector479877131(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice2 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(reader.GetFieldValue(0)); + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightInvoice2Selector479877131 + + + // START: IdentityMapInvoice2Selector479877131 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapInvoice2Selector479877131 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapInvoice2Selector479877131(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice2 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = _serializer.FromJson(reader, 1); + _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 = new ValueTypeTests.StrongTypedId.Invoice2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapInvoice2Selector479877131 + + + // START: DirtyTrackingInvoice2Selector479877131 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingInvoice2Selector479877131 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingInvoice2Selector479877131(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice2 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = _serializer.FromJson(reader, 1); + _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 = new ValueTypeTests.StrongTypedId.Invoice2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingInvoice2Selector479877131 + + + // START: QueryOnlyInvoice2DocumentStorage479877131 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyInvoice2DocumentStorage479877131 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyInvoice2DocumentStorage479877131(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyInvoice2Selector479877131(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyInvoice2DocumentStorage479877131 + + + // START: LightweightInvoice2DocumentStorage479877131 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightInvoice2DocumentStorage479877131 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightInvoice2DocumentStorage479877131(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightInvoice2Selector479877131(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightInvoice2DocumentStorage479877131 + + + // START: IdentityMapInvoice2DocumentStorage479877131 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapInvoice2DocumentStorage479877131 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapInvoice2DocumentStorage479877131(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapInvoice2Selector479877131(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapInvoice2DocumentStorage479877131 + + + // START: DirtyTrackingInvoice2DocumentStorage479877131 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingInvoice2DocumentStorage479877131 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingInvoice2DocumentStorage479877131(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingInvoice2Selector479877131(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingInvoice2DocumentStorage479877131 + + + // START: Invoice2BulkLoader479877131 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class Invoice2BulkLoader479877131 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public Invoice2BulkLoader479877131(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed1.mt_doc_invoice2(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_invoice2_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed1.mt_doc_invoice2 (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_invoice2_temp.\"id\", mt_doc_invoice2_temp.\"data\", mt_doc_invoice2_temp.\"mt_version\", mt_doc_invoice2_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_invoice2_temp left join strong_typed1.mt_doc_invoice2 on mt_doc_invoice2_temp.id = strong_typed1.mt_doc_invoice2.id where strong_typed1.mt_doc_invoice2.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed1.mt_doc_invoice2 target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_invoice2_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_invoice2_temp (like strong_typed1.mt_doc_invoice2 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, ValueTypeTests.StrongTypedId.Invoice2 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.Value.Value, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(JasperFx.Core.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, 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: Invoice2BulkLoader479877131 + + + // START: Invoice2Provider479877131 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class Invoice2Provider479877131 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public Invoice2Provider479877131(Marten.Schema.DocumentMapping mapping) : base(new Invoice2BulkLoader479877131(new QueryOnlyInvoice2DocumentStorage479877131(mapping)), new QueryOnlyInvoice2DocumentStorage479877131(mapping), new LightweightInvoice2DocumentStorage479877131(mapping), new IdentityMapInvoice2DocumentStorage479877131(mapping), new DirtyTrackingInvoice2DocumentStorage479877131(mapping)) + { + _mapping = mapping; + } + + + } + + // END: Invoice2Provider479877131 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/Invoice3Provider479877132.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Invoice3Provider479877132.cs new file mode 100644 index 0000000000..d493e9a8b4 --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Invoice3Provider479877132.cs @@ -0,0 +1,830 @@ +// +#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.StrongTypedId; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertInvoice3Operation479877132 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpsertInvoice3Operation479877132 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Invoice3 _document; + private readonly ValueTypeTests.StrongTypedId.Invoice2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertInvoice3Operation479877132(ValueTypeTests.StrongTypedId.Invoice3 document, ValueTypeTests.StrongTypedId.Invoice2Id 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.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed21.mt_upsert_invoice3("); + 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.Value); + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertInvoice3Operation479877132 + + + // START: InsertInvoice3Operation479877132 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class InsertInvoice3Operation479877132 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Invoice3 _document; + private readonly ValueTypeTests.StrongTypedId.Invoice2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertInvoice3Operation479877132(ValueTypeTests.StrongTypedId.Invoice3 document, ValueTypeTests.StrongTypedId.Invoice2Id 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.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed21.mt_insert_invoice3("); + 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.Value); + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertInvoice3Operation479877132 + + + // START: UpdateInvoice3Operation479877132 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpdateInvoice3Operation479877132 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Invoice3 _document; + private readonly ValueTypeTests.StrongTypedId.Invoice2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateInvoice3Operation479877132(ValueTypeTests.StrongTypedId.Invoice3 document, ValueTypeTests.StrongTypedId.Invoice2Id 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(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + 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, ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed21.mt_update_invoice3("); + 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.Value); + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateInvoice3Operation479877132 + + + // START: QueryOnlyInvoice3Selector479877132 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyInvoice3Selector479877132 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyInvoice3Selector479877132(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice3 Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyInvoice3Selector479877132 + + + // START: LightweightInvoice3Selector479877132 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightInvoice3Selector479877132 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightInvoice3Selector479877132(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice3 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(reader.GetFieldValue(0)); + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightInvoice3Selector479877132 + + + // START: IdentityMapInvoice3Selector479877132 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapInvoice3Selector479877132 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapInvoice3Selector479877132(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice3 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = _serializer.FromJson(reader, 1); + _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 = new ValueTypeTests.StrongTypedId.Invoice2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapInvoice3Selector479877132 + + + // START: DirtyTrackingInvoice3Selector479877132 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingInvoice3Selector479877132 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingInvoice3Selector479877132(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice3 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = _serializer.FromJson(reader, 1); + _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 = new ValueTypeTests.StrongTypedId.Invoice2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingInvoice3Selector479877132 + + + // START: QueryOnlyInvoice3DocumentStorage479877132 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyInvoice3DocumentStorage479877132 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyInvoice3DocumentStorage479877132(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id.Value == default) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyInvoice3Selector479877132(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyInvoice3DocumentStorage479877132 + + + // START: LightweightInvoice3DocumentStorage479877132 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightInvoice3DocumentStorage479877132 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightInvoice3DocumentStorage479877132(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id.Value == default) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightInvoice3Selector479877132(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightInvoice3DocumentStorage479877132 + + + // START: IdentityMapInvoice3DocumentStorage479877132 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapInvoice3DocumentStorage479877132 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapInvoice3DocumentStorage479877132(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id.Value == default) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapInvoice3Selector479877132(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapInvoice3DocumentStorage479877132 + + + // START: DirtyTrackingInvoice3DocumentStorage479877132 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingInvoice3DocumentStorage479877132 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingInvoice3DocumentStorage479877132(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id.Value == default) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingInvoice3Selector479877132(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingInvoice3DocumentStorage479877132 + + + // START: Invoice3BulkLoader479877132 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class Invoice3BulkLoader479877132 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public Invoice3BulkLoader479877132(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed21.mt_doc_invoice3(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_invoice3_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed21.mt_doc_invoice3 (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_invoice3_temp.\"id\", mt_doc_invoice3_temp.\"data\", mt_doc_invoice3_temp.\"mt_version\", mt_doc_invoice3_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_invoice3_temp left join strong_typed21.mt_doc_invoice3 on mt_doc_invoice3_temp.id = strong_typed21.mt_doc_invoice3.id where strong_typed21.mt_doc_invoice3.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed21.mt_doc_invoice3 target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_invoice3_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_invoice3_temp (like strong_typed21.mt_doc_invoice3 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, ValueTypeTests.StrongTypedId.Invoice3 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.Value, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(JasperFx.Core.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, 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: Invoice3BulkLoader479877132 + + + // START: Invoice3Provider479877132 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class Invoice3Provider479877132 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public Invoice3Provider479877132(Marten.Schema.DocumentMapping mapping) : base(new Invoice3BulkLoader479877132(new QueryOnlyInvoice3DocumentStorage479877132(mapping)), new QueryOnlyInvoice3DocumentStorage479877132(mapping), new LightweightInvoice3DocumentStorage479877132(mapping), new IdentityMapInvoice3DocumentStorage479877132(mapping), new DirtyTrackingInvoice3DocumentStorage479877132(mapping)) + { + _mapping = mapping; + } + + + } + + // END: Invoice3Provider479877132 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/InvoiceProvider1724721064.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/InvoiceProvider1724721064.cs new file mode 100644 index 0000000000..e345b78e53 --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/InvoiceProvider1724721064.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.VogenIds; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertInvoiceOperation1724721064 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpsertInvoiceOperation1724721064 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.VogenIds.Invoice _document; + private readonly ValueTypeTests.VogenIds.InvoiceId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertInvoiceOperation1724721064(ValueTypeTests.VogenIds.Invoice document, ValueTypeTests.VogenIds.InvoiceId 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.VogenIds.Invoice document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed5.mt_upsert_invoice("); + 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(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertInvoiceOperation1724721064 + + + // START: InsertInvoiceOperation1724721064 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class InsertInvoiceOperation1724721064 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.VogenIds.Invoice _document; + private readonly ValueTypeTests.VogenIds.InvoiceId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertInvoiceOperation1724721064(ValueTypeTests.VogenIds.Invoice document, ValueTypeTests.VogenIds.InvoiceId 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.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed5.mt_insert_invoice("); + 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(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertInvoiceOperation1724721064 + + + // START: UpdateInvoiceOperation1724721064 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpdateInvoiceOperation1724721064 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.VogenIds.Invoice _document; + private readonly ValueTypeTests.VogenIds.InvoiceId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateInvoiceOperation1724721064(ValueTypeTests.VogenIds.Invoice document, ValueTypeTests.VogenIds.InvoiceId 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(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + 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, ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed5.mt_update_invoice("); + 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(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateInvoiceOperation1724721064 + + + // START: QueryOnlyInvoiceSelector1724721064 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyInvoiceSelector1724721064 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyInvoiceSelector1724721064(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.VogenIds.Invoice Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.VogenIds.Invoice document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.VogenIds.Invoice document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyInvoiceSelector1724721064 + + + // START: LightweightInvoiceSelector1724721064 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightInvoiceSelector1724721064 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightInvoiceSelector1724721064(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.VogenIds.Invoice Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.VogenIds.InvoiceId.From(reader.GetFieldValue(0)); + + ValueTypeTests.VogenIds.Invoice document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.VogenIds.InvoiceId.From(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.VogenIds.Invoice document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightInvoiceSelector1724721064 + + + // START: IdentityMapInvoiceSelector1724721064 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapInvoiceSelector1724721064 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapInvoiceSelector1724721064(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.VogenIds.Invoice Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.VogenIds.InvoiceId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.VogenIds.Invoice document; + document = _serializer.FromJson(reader, 1); + _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 = ValueTypeTests.VogenIds.InvoiceId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.VogenIds.Invoice document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapInvoiceSelector1724721064 + + + // START: DirtyTrackingInvoiceSelector1724721064 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingInvoiceSelector1724721064 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingInvoiceSelector1724721064(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.VogenIds.Invoice Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.VogenIds.InvoiceId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.VogenIds.Invoice document; + document = _serializer.FromJson(reader, 1); + _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 = ValueTypeTests.VogenIds.InvoiceId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.VogenIds.Invoice document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingInvoiceSelector1724721064 + + + // START: QueryOnlyInvoiceDocumentStorage1724721064 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyInvoiceDocumentStorage1724721064 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyInvoiceDocumentStorage1724721064(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.VogenIds.InvoiceId AssignIdentity(ValueTypeTests.VogenIds.Invoice document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.VogenIds.InvoiceId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoiceOperation1724721064 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoiceOperation1724721064 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoiceOperation1724721064 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.VogenIds.InvoiceId Identity(ValueTypeTests.VogenIds.Invoice document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyInvoiceSelector1724721064(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.VogenIds.InvoiceId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.VogenIds.InvoiceId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyInvoiceDocumentStorage1724721064 + + + // START: LightweightInvoiceDocumentStorage1724721064 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightInvoiceDocumentStorage1724721064 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightInvoiceDocumentStorage1724721064(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.VogenIds.InvoiceId AssignIdentity(ValueTypeTests.VogenIds.Invoice document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.VogenIds.InvoiceId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoiceOperation1724721064 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoiceOperation1724721064 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoiceOperation1724721064 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.VogenIds.InvoiceId Identity(ValueTypeTests.VogenIds.Invoice document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightInvoiceSelector1724721064(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.VogenIds.InvoiceId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.VogenIds.InvoiceId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightInvoiceDocumentStorage1724721064 + + + // START: IdentityMapInvoiceDocumentStorage1724721064 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapInvoiceDocumentStorage1724721064 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapInvoiceDocumentStorage1724721064(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.VogenIds.InvoiceId AssignIdentity(ValueTypeTests.VogenIds.Invoice document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.VogenIds.InvoiceId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoiceOperation1724721064 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoiceOperation1724721064 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoiceOperation1724721064 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.VogenIds.InvoiceId Identity(ValueTypeTests.VogenIds.Invoice document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapInvoiceSelector1724721064(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.VogenIds.InvoiceId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.VogenIds.InvoiceId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapInvoiceDocumentStorage1724721064 + + + // START: DirtyTrackingInvoiceDocumentStorage1724721064 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingInvoiceDocumentStorage1724721064 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingInvoiceDocumentStorage1724721064(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.VogenIds.InvoiceId AssignIdentity(ValueTypeTests.VogenIds.Invoice document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.VogenIds.InvoiceId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoiceOperation1724721064 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoiceOperation1724721064 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoiceOperation1724721064 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.VogenIds.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.VogenIds.InvoiceId Identity(ValueTypeTests.VogenIds.Invoice document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingInvoiceSelector1724721064(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.VogenIds.InvoiceId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.VogenIds.InvoiceId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingInvoiceDocumentStorage1724721064 + + + // START: InvoiceBulkLoader1724721064 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class InvoiceBulkLoader1724721064 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public InvoiceBulkLoader1724721064(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed5.mt_doc_invoice(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_invoice_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed5.mt_doc_invoice (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_invoice_temp.\"id\", mt_doc_invoice_temp.\"data\", mt_doc_invoice_temp.\"mt_version\", mt_doc_invoice_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_invoice_temp left join strong_typed5.mt_doc_invoice on mt_doc_invoice_temp.id = strong_typed5.mt_doc_invoice.id where strong_typed5.mt_doc_invoice.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed5.mt_doc_invoice target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_invoice_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_invoice_temp (like strong_typed5.mt_doc_invoice 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, ValueTypeTests.VogenIds.Invoice 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.Value.Value, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(JasperFx.Core.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, 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: InvoiceBulkLoader1724721064 + + + // START: InvoiceProvider1724721064 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class InvoiceProvider1724721064 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public InvoiceProvider1724721064(Marten.Schema.DocumentMapping mapping) : base(new InvoiceBulkLoader1724721064(new QueryOnlyInvoiceDocumentStorage1724721064(mapping)), new QueryOnlyInvoiceDocumentStorage1724721064(mapping), new LightweightInvoiceDocumentStorage1724721064(mapping), new IdentityMapInvoiceDocumentStorage1724721064(mapping), new DirtyTrackingInvoiceDocumentStorage1724721064(mapping)) + { + _mapping = mapping; + } + + + } + + // END: InvoiceProvider1724721064 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/OrderProvider347010495.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/OrderProvider347010495.cs new file mode 100644 index 0000000000..73269cb598 --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/OrderProvider347010495.cs @@ -0,0 +1,858 @@ +// +#pragma warning disable +using Marten.Internal; +using Marten.Internal.Storage; +using Marten.Schema; +using Marten.Schema.Arguments; +using Npgsql; +using System.Collections.Generic; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertOrderOperation347010495 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpsertOrderOperation347010495 : Marten.Internal.Operations.StorageOperation + { + private readonly FSharpTypes.Order _document; + private readonly FSharpTypes.OrderId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertOrderOperation347010495(FSharpTypes.Order document, FSharpTypes.OrderId 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, FSharpTypes.Order document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed_fsharp.mt_upsert_fsharptypes_order("); + 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.Item); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertOrderOperation347010495 + + + // START: InsertOrderOperation347010495 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class InsertOrderOperation347010495 : Marten.Internal.Operations.StorageOperation + { + private readonly FSharpTypes.Order _document; + private readonly FSharpTypes.OrderId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertOrderOperation347010495(FSharpTypes.Order document, FSharpTypes.OrderId 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.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, FSharpTypes.Order document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed_fsharp.mt_insert_fsharptypes_order("); + 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.Item); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertOrderOperation347010495 + + + // START: UpdateOrderOperation347010495 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpdateOrderOperation347010495 : Marten.Internal.Operations.StorageOperation + { + private readonly FSharpTypes.Order _document; + private readonly FSharpTypes.OrderId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateOrderOperation347010495(FSharpTypes.Order document, FSharpTypes.OrderId 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(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + 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, FSharpTypes.Order document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed_fsharp.mt_update_fsharptypes_order("); + 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.Item); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateOrderOperation347010495 + + + // START: QueryOnlyOrderSelector347010495 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyOrderSelector347010495 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyOrderSelector347010495(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public FSharpTypes.Order Resolve(System.Data.Common.DbDataReader reader) + { + + FSharpTypes.Order document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + FSharpTypes.Order document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyOrderSelector347010495 + + + // START: LightweightOrderSelector347010495 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightOrderSelector347010495 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightOrderSelector347010495(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public FSharpTypes.Order Resolve(System.Data.Common.DbDataReader reader) + { + var id = FSharpTypes.OrderId.NewId(reader.GetFieldValue(0)); + + FSharpTypes.Order document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = FSharpTypes.OrderId.NewId(await reader.GetFieldValueAsync(0, token)); + + FSharpTypes.Order document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightOrderSelector347010495 + + + // START: IdentityMapOrderSelector347010495 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapOrderSelector347010495 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapOrderSelector347010495(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public FSharpTypes.Order Resolve(System.Data.Common.DbDataReader reader) + { + var id = FSharpTypes.OrderId.NewId(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + FSharpTypes.Order document; + document = _serializer.FromJson(reader, 1); + _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 = FSharpTypes.OrderId.NewId(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + FSharpTypes.Order document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapOrderSelector347010495 + + + // START: DirtyTrackingOrderSelector347010495 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingOrderSelector347010495 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingOrderSelector347010495(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public FSharpTypes.Order Resolve(System.Data.Common.DbDataReader reader) + { + var id = FSharpTypes.OrderId.NewId(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + FSharpTypes.Order document; + document = _serializer.FromJson(reader, 1); + _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 = FSharpTypes.OrderId.NewId(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + FSharpTypes.Order document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingOrderSelector347010495 + + + // START: QueryOnlyOrderDocumentStorage347010495 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyOrderDocumentStorage347010495 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyOrderDocumentStorage347010495(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(FSharpTypes.Order document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(FSharpTypes.Order document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyOrderSelector347010495(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyOrderDocumentStorage347010495 + + + // START: LightweightOrderDocumentStorage347010495 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightOrderDocumentStorage347010495 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightOrderDocumentStorage347010495(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(FSharpTypes.Order document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(FSharpTypes.Order document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightOrderSelector347010495(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightOrderDocumentStorage347010495 + + + // START: IdentityMapOrderDocumentStorage347010495 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapOrderDocumentStorage347010495 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapOrderDocumentStorage347010495(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(FSharpTypes.Order document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(FSharpTypes.Order document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapOrderSelector347010495(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapOrderDocumentStorage347010495 + + + // START: DirtyTrackingOrderDocumentStorage347010495 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingOrderDocumentStorage347010495 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingOrderDocumentStorage347010495(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(FSharpTypes.Order document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(FSharpTypes.Order document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingOrderSelector347010495(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingOrderDocumentStorage347010495 + + + // START: OrderBulkLoader347010495 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class OrderBulkLoader347010495 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public OrderBulkLoader347010495(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed_fsharp.mt_doc_fsharptypes_order(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_fsharptypes_order_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed_fsharp.mt_doc_fsharptypes_order (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_fsharptypes_order_temp.\"id\", mt_doc_fsharptypes_order_temp.\"data\", mt_doc_fsharptypes_order_temp.\"mt_version\", mt_doc_fsharptypes_order_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_fsharptypes_order_temp left join strong_typed_fsharp.mt_doc_fsharptypes_order on mt_doc_fsharptypes_order_temp.id = strong_typed_fsharp.mt_doc_fsharptypes_order.id where strong_typed_fsharp.mt_doc_fsharptypes_order.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed_fsharp.mt_doc_fsharptypes_order target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_fsharptypes_order_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_fsharptypes_order_temp (like strong_typed_fsharp.mt_doc_fsharptypes_order 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, FSharpTypes.Order 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.Item, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(JasperFx.Core.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, 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: OrderBulkLoader347010495 + + + // START: OrderProvider347010495 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class OrderProvider347010495 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public OrderProvider347010495(Marten.Schema.DocumentMapping mapping) : base(new OrderBulkLoader347010495(new QueryOnlyOrderDocumentStorage347010495(mapping)), new QueryOnlyOrderDocumentStorage347010495(mapping), new LightweightOrderDocumentStorage347010495(mapping), new IdentityMapOrderDocumentStorage347010495(mapping), new DirtyTrackingOrderDocumentStorage347010495(mapping)) + { + _mapping = mapping; + } + + + } + + // END: OrderProvider347010495 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/ReferenceTypeOrderProvider1892982689.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/ReferenceTypeOrderProvider1892982689.cs new file mode 100644 index 0000000000..98c75e9647 --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/ReferenceTypeOrderProvider1892982689.cs @@ -0,0 +1,859 @@ +// +#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.StrongTypedId; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertReferenceTypeOrderOperation1892982689 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpsertReferenceTypeOrderOperation1892982689 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.ReferenceTypeOrder _document; + private readonly FSharpTypes.OrderId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertReferenceTypeOrderOperation1892982689(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, FSharpTypes.OrderId 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.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed_fsharp.mt_upsert_referencetypeorder("); + 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.Item); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertReferenceTypeOrderOperation1892982689 + + + // START: InsertReferenceTypeOrderOperation1892982689 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class InsertReferenceTypeOrderOperation1892982689 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.ReferenceTypeOrder _document; + private readonly FSharpTypes.OrderId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertReferenceTypeOrderOperation1892982689(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, FSharpTypes.OrderId 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.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed_fsharp.mt_insert_referencetypeorder("); + 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.Item); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertReferenceTypeOrderOperation1892982689 + + + // START: UpdateReferenceTypeOrderOperation1892982689 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpdateReferenceTypeOrderOperation1892982689 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.ReferenceTypeOrder _document; + private readonly FSharpTypes.OrderId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateReferenceTypeOrderOperation1892982689(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, FSharpTypes.OrderId 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(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + 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, ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed_fsharp.mt_update_referencetypeorder("); + 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.Item); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateReferenceTypeOrderOperation1892982689 + + + // START: QueryOnlyReferenceTypeOrderSelector1892982689 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyReferenceTypeOrderSelector1892982689 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyReferenceTypeOrderSelector1892982689(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.ReferenceTypeOrder Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyReferenceTypeOrderSelector1892982689 + + + // START: LightweightReferenceTypeOrderSelector1892982689 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightReferenceTypeOrderSelector1892982689 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightReferenceTypeOrderSelector1892982689(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.ReferenceTypeOrder Resolve(System.Data.Common.DbDataReader reader) + { + var id = FSharpTypes.OrderId.NewId(reader.GetFieldValue(0)); + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = FSharpTypes.OrderId.NewId(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightReferenceTypeOrderSelector1892982689 + + + // START: IdentityMapReferenceTypeOrderSelector1892982689 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapReferenceTypeOrderSelector1892982689 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapReferenceTypeOrderSelector1892982689(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.ReferenceTypeOrder Resolve(System.Data.Common.DbDataReader reader) + { + var id = FSharpTypes.OrderId.NewId(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = _serializer.FromJson(reader, 1); + _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 = FSharpTypes.OrderId.NewId(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapReferenceTypeOrderSelector1892982689 + + + // START: DirtyTrackingReferenceTypeOrderSelector1892982689 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingReferenceTypeOrderSelector1892982689 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingReferenceTypeOrderSelector1892982689(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.ReferenceTypeOrder Resolve(System.Data.Common.DbDataReader reader) + { + var id = FSharpTypes.OrderId.NewId(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = _serializer.FromJson(reader, 1); + _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 = FSharpTypes.OrderId.NewId(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingReferenceTypeOrderSelector1892982689 + + + // START: QueryOnlyReferenceTypeOrderDocumentStorage1892982689 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyReferenceTypeOrderDocumentStorage1892982689 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyReferenceTypeOrderDocumentStorage1892982689(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyReferenceTypeOrderSelector1892982689(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyReferenceTypeOrderDocumentStorage1892982689 + + + // START: LightweightReferenceTypeOrderDocumentStorage1892982689 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightReferenceTypeOrderDocumentStorage1892982689 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightReferenceTypeOrderDocumentStorage1892982689(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightReferenceTypeOrderSelector1892982689(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightReferenceTypeOrderDocumentStorage1892982689 + + + // START: IdentityMapReferenceTypeOrderDocumentStorage1892982689 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapReferenceTypeOrderDocumentStorage1892982689 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapReferenceTypeOrderDocumentStorage1892982689(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapReferenceTypeOrderSelector1892982689(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapReferenceTypeOrderDocumentStorage1892982689 + + + // START: DirtyTrackingReferenceTypeOrderDocumentStorage1892982689 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingReferenceTypeOrderDocumentStorage1892982689 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingReferenceTypeOrderDocumentStorage1892982689(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingReferenceTypeOrderSelector1892982689(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingReferenceTypeOrderDocumentStorage1892982689 + + + // START: ReferenceTypeOrderBulkLoader1892982689 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class ReferenceTypeOrderBulkLoader1892982689 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public ReferenceTypeOrderBulkLoader1892982689(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed_fsharp.mt_doc_referencetypeorder(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_referencetypeorder_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed_fsharp.mt_doc_referencetypeorder (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_referencetypeorder_temp.\"id\", mt_doc_referencetypeorder_temp.\"data\", mt_doc_referencetypeorder_temp.\"mt_version\", mt_doc_referencetypeorder_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_referencetypeorder_temp left join strong_typed_fsharp.mt_doc_referencetypeorder on mt_doc_referencetypeorder_temp.id = strong_typed_fsharp.mt_doc_referencetypeorder.id where strong_typed_fsharp.mt_doc_referencetypeorder.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed_fsharp.mt_doc_referencetypeorder target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_referencetypeorder_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_referencetypeorder_temp (like strong_typed_fsharp.mt_doc_referencetypeorder 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, ValueTypeTests.StrongTypedId.ReferenceTypeOrder 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.Item, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(JasperFx.Core.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, 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: ReferenceTypeOrderBulkLoader1892982689 + + + // START: ReferenceTypeOrderProvider1892982689 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class ReferenceTypeOrderProvider1892982689 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public ReferenceTypeOrderProvider1892982689(Marten.Schema.DocumentMapping mapping) : base(new ReferenceTypeOrderBulkLoader1892982689(new QueryOnlyReferenceTypeOrderDocumentStorage1892982689(mapping)), new QueryOnlyReferenceTypeOrderDocumentStorage1892982689(mapping), new LightweightReferenceTypeOrderDocumentStorage1892982689(mapping), new IdentityMapReferenceTypeOrderDocumentStorage1892982689(mapping), new DirtyTrackingReferenceTypeOrderDocumentStorage1892982689(mapping)) + { + _mapping = mapping; + } + + + } + + // END: ReferenceTypeOrderProvider1892982689 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/TeacherProvider944571072.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/TeacherProvider944571072.cs new file mode 100644 index 0000000000..22b00630de --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/TeacherProvider944571072.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: UpsertTeacherOperation944571072 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpsertTeacherOperation944571072 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Teacher _document; + private readonly ValueTypeTests.TeacherId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertTeacherOperation944571072(ValueTypeTests.Teacher document, ValueTypeTests.TeacherId 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.Teacher document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_upsert_teacher("); + 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(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertTeacherOperation944571072 + + + // START: InsertTeacherOperation944571072 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class InsertTeacherOperation944571072 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Teacher _document; + private readonly ValueTypeTests.TeacherId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertTeacherOperation944571072(ValueTypeTests.Teacher document, ValueTypeTests.TeacherId 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.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_insert_teacher("); + 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(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertTeacherOperation944571072 + + + // START: UpdateTeacherOperation944571072 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpdateTeacherOperation944571072 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Teacher _document; + private readonly ValueTypeTests.TeacherId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateTeacherOperation944571072(ValueTypeTests.Teacher document, ValueTypeTests.TeacherId 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(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + 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, ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_update_teacher("); + 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(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateTeacherOperation944571072 + + + // START: QueryOnlyTeacherSelector944571072 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyTeacherSelector944571072 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyTeacherSelector944571072(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Teacher Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.Teacher document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.Teacher document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyTeacherSelector944571072 + + + // START: LightweightTeacherSelector944571072 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightTeacherSelector944571072 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightTeacherSelector944571072(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Teacher Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.TeacherId.From(reader.GetFieldValue(0)); + + ValueTypeTests.Teacher document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.TeacherId.From(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.Teacher document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightTeacherSelector944571072 + + + // START: IdentityMapTeacherSelector944571072 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapTeacherSelector944571072 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapTeacherSelector944571072(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Teacher Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.TeacherId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Teacher document; + document = _serializer.FromJson(reader, 1); + _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 = ValueTypeTests.TeacherId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Teacher document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapTeacherSelector944571072 + + + // START: DirtyTrackingTeacherSelector944571072 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingTeacherSelector944571072 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingTeacherSelector944571072(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Teacher Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.TeacherId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Teacher document; + document = _serializer.FromJson(reader, 1); + _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 = ValueTypeTests.TeacherId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Teacher document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingTeacherSelector944571072 + + + // START: QueryOnlyTeacherDocumentStorage944571072 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyTeacherDocumentStorage944571072 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyTeacherDocumentStorage944571072(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.TeacherId AssignIdentity(ValueTypeTests.Teacher document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.TeacherId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.TeacherId Identity(ValueTypeTests.Teacher document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyTeacherSelector944571072(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.TeacherId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.TeacherId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyTeacherDocumentStorage944571072 + + + // START: LightweightTeacherDocumentStorage944571072 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightTeacherDocumentStorage944571072 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightTeacherDocumentStorage944571072(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.TeacherId AssignIdentity(ValueTypeTests.Teacher document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.TeacherId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.TeacherId Identity(ValueTypeTests.Teacher document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightTeacherSelector944571072(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.TeacherId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.TeacherId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightTeacherDocumentStorage944571072 + + + // START: IdentityMapTeacherDocumentStorage944571072 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapTeacherDocumentStorage944571072 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapTeacherDocumentStorage944571072(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.TeacherId AssignIdentity(ValueTypeTests.Teacher document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.TeacherId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.TeacherId Identity(ValueTypeTests.Teacher document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapTeacherSelector944571072(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.TeacherId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.TeacherId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapTeacherDocumentStorage944571072 + + + // START: DirtyTrackingTeacherDocumentStorage944571072 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingTeacherDocumentStorage944571072 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingTeacherDocumentStorage944571072(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.TeacherId AssignIdentity(ValueTypeTests.Teacher document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.TeacherId.From(JasperFx.Core.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.TeacherId Identity(ValueTypeTests.Teacher document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingTeacherSelector944571072(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.TeacherId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.TeacherId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingTeacherDocumentStorage944571072 + + + // START: TeacherBulkLoader944571072 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class TeacherBulkLoader944571072 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public TeacherBulkLoader944571072(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed24.mt_doc_teacher(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_teacher_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed24.mt_doc_teacher (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_teacher_temp.\"id\", mt_doc_teacher_temp.\"data\", mt_doc_teacher_temp.\"mt_version\", mt_doc_teacher_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_teacher_temp left join strong_typed24.mt_doc_teacher on mt_doc_teacher_temp.id = strong_typed24.mt_doc_teacher.id where strong_typed24.mt_doc_teacher.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed24.mt_doc_teacher target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_teacher_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_teacher_temp (like strong_typed24.mt_doc_teacher 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, ValueTypeTests.Teacher 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.Value.Value, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(JasperFx.Core.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, 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: TeacherBulkLoader944571072 + + + // START: TeacherProvider944571072 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class TeacherProvider944571072 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public TeacherProvider944571072(Marten.Schema.DocumentMapping mapping) : base(new TeacherBulkLoader944571072(new QueryOnlyTeacherDocumentStorage944571072(mapping)), new QueryOnlyTeacherDocumentStorage944571072(mapping), new LightweightTeacherDocumentStorage944571072(mapping), new IdentityMapTeacherDocumentStorage944571072(mapping), new DirtyTrackingTeacherDocumentStorage944571072(mapping)) + { + _mapping = mapping; + } + + + } + + // END: TeacherProvider944571072 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/Team2Provider1170066519.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Team2Provider1170066519.cs new file mode 100644 index 0000000000..570d19ec9c --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Team2Provider1170066519.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.StrongTypedId; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertTeam2Operation1170066519 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpsertTeam2Operation1170066519 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Team2 _document; + private readonly ValueTypeTests.StrongTypedId.Team2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertTeam2Operation1170066519(ValueTypeTests.StrongTypedId.Team2 document, ValueTypeTests.StrongTypedId.Team2Id 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.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed4.mt_upsert_team2("); + 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.Text; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertTeam2Operation1170066519 + + + // START: InsertTeam2Operation1170066519 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class InsertTeam2Operation1170066519 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Team2 _document; + private readonly ValueTypeTests.StrongTypedId.Team2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertTeam2Operation1170066519(ValueTypeTests.StrongTypedId.Team2 document, ValueTypeTests.StrongTypedId.Team2Id 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.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed4.mt_insert_team2("); + 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.Text; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertTeam2Operation1170066519 + + + // START: UpdateTeam2Operation1170066519 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpdateTeam2Operation1170066519 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Team2 _document; + private readonly ValueTypeTests.StrongTypedId.Team2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateTeam2Operation1170066519(ValueTypeTests.StrongTypedId.Team2 document, ValueTypeTests.StrongTypedId.Team2Id 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(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Update; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed4.mt_update_team2("); + 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.Text; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateTeam2Operation1170066519 + + + // START: QueryOnlyTeam2Selector1170066519 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyTeam2Selector1170066519 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyTeam2Selector1170066519(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team2 Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.StrongTypedId.Team2 document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.StrongTypedId.Team2 document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyTeam2Selector1170066519 + + + // START: LightweightTeam2Selector1170066519 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightTeam2Selector1170066519 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightTeam2Selector1170066519(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team2 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(reader.GetFieldValue(0)); + + ValueTypeTests.StrongTypedId.Team2 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.StrongTypedId.Team2 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightTeam2Selector1170066519 + + + // START: IdentityMapTeam2Selector1170066519 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapTeam2Selector1170066519 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapTeam2Selector1170066519(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team2 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team2 document; + document = _serializer.FromJson(reader, 1); + _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 = new ValueTypeTests.StrongTypedId.Team2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team2 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapTeam2Selector1170066519 + + + // START: DirtyTrackingTeam2Selector1170066519 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingTeam2Selector1170066519 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingTeam2Selector1170066519(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team2 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team2 document; + document = _serializer.FromJson(reader, 1); + _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 = new ValueTypeTests.StrongTypedId.Team2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team2 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingTeam2Selector1170066519 + + + // START: QueryOnlyTeam2DocumentStorage1170066519 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyTeam2DocumentStorage1170066519 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyTeam2DocumentStorage1170066519(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyTeam2Selector1170066519(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: QueryOnlyTeam2DocumentStorage1170066519 + + + // START: LightweightTeam2DocumentStorage1170066519 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightTeam2DocumentStorage1170066519 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightTeam2DocumentStorage1170066519(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightTeam2Selector1170066519(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: LightweightTeam2DocumentStorage1170066519 + + + // START: IdentityMapTeam2DocumentStorage1170066519 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapTeam2DocumentStorage1170066519 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapTeam2DocumentStorage1170066519(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapTeam2Selector1170066519(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: IdentityMapTeam2DocumentStorage1170066519 + + + // START: DirtyTrackingTeam2DocumentStorage1170066519 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingTeam2DocumentStorage1170066519 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingTeam2DocumentStorage1170066519(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingTeam2Selector1170066519(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: DirtyTrackingTeam2DocumentStorage1170066519 + + + // START: Team2BulkLoader1170066519 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class Team2BulkLoader1170066519 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public Team2BulkLoader1170066519(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed4.mt_doc_team2(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_team2_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed4.mt_doc_team2 (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_team2_temp.\"id\", mt_doc_team2_temp.\"data\", mt_doc_team2_temp.\"mt_version\", mt_doc_team2_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_team2_temp left join strong_typed4.mt_doc_team2 on mt_doc_team2_temp.id = strong_typed4.mt_doc_team2.id where strong_typed4.mt_doc_team2.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed4.mt_doc_team2 target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_team2_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_team2_temp (like strong_typed4.mt_doc_team2 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, ValueTypeTests.StrongTypedId.Team2 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.Value.Value, NpgsqlTypes.NpgsqlDbType.Text, cancellation); + await writer.WriteAsync(JasperFx.Core.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, 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: Team2BulkLoader1170066519 + + + // START: Team2Provider1170066519 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class Team2Provider1170066519 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public Team2Provider1170066519(Marten.Schema.DocumentMapping mapping) : base(new Team2BulkLoader1170066519(new QueryOnlyTeam2DocumentStorage1170066519(mapping)), new QueryOnlyTeam2DocumentStorage1170066519(mapping), new LightweightTeam2DocumentStorage1170066519(mapping), new IdentityMapTeam2DocumentStorage1170066519(mapping), new DirtyTrackingTeam2DocumentStorage1170066519(mapping)) + { + _mapping = mapping; + } + + + } + + // END: Team2Provider1170066519 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/Team3Provider396017422.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Team3Provider396017422.cs new file mode 100644 index 0000000000..89826e04d0 --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Team3Provider396017422.cs @@ -0,0 +1,830 @@ +// +#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.StrongTypedId; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertTeam3Operation396017422 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpsertTeam3Operation396017422 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Team3 _document; + private readonly ValueTypeTests.StrongTypedId.Team2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertTeam3Operation396017422(ValueTypeTests.StrongTypedId.Team3 document, ValueTypeTests.StrongTypedId.Team2Id 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.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed23.mt_upsert_team3("); + 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.Value); + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertTeam3Operation396017422 + + + // START: InsertTeam3Operation396017422 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class InsertTeam3Operation396017422 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Team3 _document; + private readonly ValueTypeTests.StrongTypedId.Team2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertTeam3Operation396017422(ValueTypeTests.StrongTypedId.Team3 document, ValueTypeTests.StrongTypedId.Team2Id 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.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed23.mt_insert_team3("); + 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.Value); + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertTeam3Operation396017422 + + + // START: UpdateTeam3Operation396017422 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpdateTeam3Operation396017422 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Team3 _document; + private readonly ValueTypeTests.StrongTypedId.Team2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateTeam3Operation396017422(ValueTypeTests.StrongTypedId.Team3 document, ValueTypeTests.StrongTypedId.Team2Id 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(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Update; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed23.mt_update_team3("); + 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.Value); + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateTeam3Operation396017422 + + + // START: QueryOnlyTeam3Selector396017422 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyTeam3Selector396017422 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyTeam3Selector396017422(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team3 Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.StrongTypedId.Team3 document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.StrongTypedId.Team3 document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyTeam3Selector396017422 + + + // START: LightweightTeam3Selector396017422 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightTeam3Selector396017422 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightTeam3Selector396017422(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team3 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(reader.GetFieldValue(0)); + + ValueTypeTests.StrongTypedId.Team3 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.StrongTypedId.Team3 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightTeam3Selector396017422 + + + // START: IdentityMapTeam3Selector396017422 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapTeam3Selector396017422 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapTeam3Selector396017422(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team3 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team3 document; + document = _serializer.FromJson(reader, 1); + _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 = new ValueTypeTests.StrongTypedId.Team2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team3 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapTeam3Selector396017422 + + + // START: DirtyTrackingTeam3Selector396017422 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingTeam3Selector396017422 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingTeam3Selector396017422(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team3 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team3 document; + document = _serializer.FromJson(reader, 1); + _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 = new ValueTypeTests.StrongTypedId.Team2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team3 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingTeam3Selector396017422 + + + // START: QueryOnlyTeam3DocumentStorage396017422 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyTeam3DocumentStorage396017422 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyTeam3DocumentStorage396017422(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyTeam3Selector396017422(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: QueryOnlyTeam3DocumentStorage396017422 + + + // START: LightweightTeam3DocumentStorage396017422 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightTeam3DocumentStorage396017422 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightTeam3DocumentStorage396017422(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightTeam3Selector396017422(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: LightweightTeam3DocumentStorage396017422 + + + // START: IdentityMapTeam3DocumentStorage396017422 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapTeam3DocumentStorage396017422 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapTeam3DocumentStorage396017422(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapTeam3Selector396017422(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: IdentityMapTeam3DocumentStorage396017422 + + + // START: DirtyTrackingTeam3DocumentStorage396017422 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingTeam3DocumentStorage396017422 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingTeam3DocumentStorage396017422(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingTeam3Selector396017422(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: DirtyTrackingTeam3DocumentStorage396017422 + + + // START: Team3BulkLoader396017422 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class Team3BulkLoader396017422 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public Team3BulkLoader396017422(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed23.mt_doc_team3(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_team3_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed23.mt_doc_team3 (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_team3_temp.\"id\", mt_doc_team3_temp.\"data\", mt_doc_team3_temp.\"mt_version\", mt_doc_team3_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_team3_temp left join strong_typed23.mt_doc_team3 on mt_doc_team3_temp.id = strong_typed23.mt_doc_team3.id where strong_typed23.mt_doc_team3.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed23.mt_doc_team3 target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_team3_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_team3_temp (like strong_typed23.mt_doc_team3 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, ValueTypeTests.StrongTypedId.Team3 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.Value, NpgsqlTypes.NpgsqlDbType.Text, cancellation); + await writer.WriteAsync(JasperFx.Core.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, 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: Team3BulkLoader396017422 + + + // START: Team3Provider396017422 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class Team3Provider396017422 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public Team3Provider396017422(Marten.Schema.DocumentMapping mapping) : base(new Team3BulkLoader396017422(new QueryOnlyTeam3DocumentStorage396017422(mapping)), new QueryOnlyTeam3DocumentStorage396017422(mapping), new LightweightTeam3DocumentStorage396017422(mapping), new IdentityMapTeam3DocumentStorage396017422(mapping), new DirtyTrackingTeam3DocumentStorage396017422(mapping)) + { + _mapping = mapping; + } + + + } + + // END: Team3Provider396017422 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/TeamProvider700129768.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/TeamProvider700129768.cs new file mode 100644 index 0000000000..0a549f2599 --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/TeamProvider700129768.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.VogenIds; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertTeamOperation700129768 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpsertTeamOperation700129768 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.VogenIds.Team _document; + private readonly ValueTypeTests.VogenIds.TeamId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertTeamOperation700129768(ValueTypeTests.VogenIds.Team document, ValueTypeTests.VogenIds.TeamId 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.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed8.mt_upsert_team("); + 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.Text; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertTeamOperation700129768 + + + // START: InsertTeamOperation700129768 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class InsertTeamOperation700129768 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.VogenIds.Team _document; + private readonly ValueTypeTests.VogenIds.TeamId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertTeamOperation700129768(ValueTypeTests.VogenIds.Team document, ValueTypeTests.VogenIds.TeamId 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.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed8.mt_insert_team("); + 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.Text; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertTeamOperation700129768 + + + // START: UpdateTeamOperation700129768 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class UpdateTeamOperation700129768 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.VogenIds.Team _document; + private readonly ValueTypeTests.VogenIds.TeamId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateTeamOperation700129768(ValueTypeTests.VogenIds.Team document, ValueTypeTests.VogenIds.TeamId 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(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Update; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed8.mt_update_team("); + 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.Text; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateTeamOperation700129768 + + + // START: QueryOnlyTeamSelector700129768 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyTeamSelector700129768 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyTeamSelector700129768(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.VogenIds.Team Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.VogenIds.Team document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.VogenIds.Team document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyTeamSelector700129768 + + + // START: LightweightTeamSelector700129768 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightTeamSelector700129768 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightTeamSelector700129768(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.VogenIds.Team Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.VogenIds.TeamId.From(reader.GetFieldValue(0)); + + ValueTypeTests.VogenIds.Team document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.VogenIds.TeamId.From(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.VogenIds.Team document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightTeamSelector700129768 + + + // START: IdentityMapTeamSelector700129768 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapTeamSelector700129768 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapTeamSelector700129768(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.VogenIds.Team Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.VogenIds.TeamId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.VogenIds.Team document; + document = _serializer.FromJson(reader, 1); + _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 = ValueTypeTests.VogenIds.TeamId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.VogenIds.Team document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapTeamSelector700129768 + + + // START: DirtyTrackingTeamSelector700129768 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingTeamSelector700129768 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingTeamSelector700129768(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.VogenIds.Team Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.VogenIds.TeamId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.VogenIds.Team document; + document = _serializer.FromJson(reader, 1); + _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 = ValueTypeTests.VogenIds.TeamId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.VogenIds.Team document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingTeamSelector700129768 + + + // START: QueryOnlyTeamDocumentStorage700129768 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class QueryOnlyTeamDocumentStorage700129768 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyTeamDocumentStorage700129768(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.VogenIds.TeamId AssignIdentity(ValueTypeTests.VogenIds.Team document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeamOperation700129768 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeamOperation700129768 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeamOperation700129768 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.VogenIds.TeamId Identity(ValueTypeTests.VogenIds.Team document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyTeamSelector700129768(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.VogenIds.TeamId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.VogenIds.TeamId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: QueryOnlyTeamDocumentStorage700129768 + + + // START: LightweightTeamDocumentStorage700129768 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class LightweightTeamDocumentStorage700129768 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightTeamDocumentStorage700129768(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.VogenIds.TeamId AssignIdentity(ValueTypeTests.VogenIds.Team document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeamOperation700129768 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeamOperation700129768 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeamOperation700129768 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.VogenIds.TeamId Identity(ValueTypeTests.VogenIds.Team document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightTeamSelector700129768(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.VogenIds.TeamId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.VogenIds.TeamId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: LightweightTeamDocumentStorage700129768 + + + // START: IdentityMapTeamDocumentStorage700129768 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class IdentityMapTeamDocumentStorage700129768 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapTeamDocumentStorage700129768(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.VogenIds.TeamId AssignIdentity(ValueTypeTests.VogenIds.Team document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeamOperation700129768 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeamOperation700129768 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeamOperation700129768 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.VogenIds.TeamId Identity(ValueTypeTests.VogenIds.Team document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapTeamSelector700129768(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.VogenIds.TeamId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.VogenIds.TeamId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: IdentityMapTeamDocumentStorage700129768 + + + // START: DirtyTrackingTeamDocumentStorage700129768 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class DirtyTrackingTeamDocumentStorage700129768 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingTeamDocumentStorage700129768(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.VogenIds.TeamId AssignIdentity(ValueTypeTests.VogenIds.Team document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeamOperation700129768 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeamOperation700129768 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeamOperation700129768 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.VogenIds.Team document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.VogenIds.TeamId Identity(ValueTypeTests.VogenIds.Team document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingTeamSelector700129768(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.VogenIds.TeamId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.VogenIds.TeamId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: DirtyTrackingTeamDocumentStorage700129768 + + + // START: TeamBulkLoader700129768 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class TeamBulkLoader700129768 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public TeamBulkLoader700129768(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed8.mt_doc_team(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_team_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed8.mt_doc_team (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_team_temp.\"id\", mt_doc_team_temp.\"data\", mt_doc_team_temp.\"mt_version\", mt_doc_team_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_team_temp left join strong_typed8.mt_doc_team on mt_doc_team_temp.id = strong_typed8.mt_doc_team.id where strong_typed8.mt_doc_team.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed8.mt_doc_team target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_team_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_team_temp (like strong_typed8.mt_doc_team 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, ValueTypeTests.VogenIds.Team 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.Value.Value, NpgsqlTypes.NpgsqlDbType.Text, cancellation); + await writer.WriteAsync(JasperFx.Core.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, 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: TeamBulkLoader700129768 + + + // START: TeamProvider700129768 + [global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")] + public sealed class TeamProvider700129768 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public TeamProvider700129768(Marten.Schema.DocumentMapping mapping) : base(new TeamBulkLoader700129768(new QueryOnlyTeamDocumentStorage700129768(mapping)), new QueryOnlyTeamDocumentStorage700129768(mapping), new LightweightTeamDocumentStorage700129768(mapping), new IdentityMapTeamDocumentStorage700129768(mapping), new DirtyTrackingTeamDocumentStorage700129768(mapping)) + { + _mapping = mapping; + } + + + } + + // END: TeamProvider700129768 + + +} +