Example #1
0
                /// <summary>
                /// Builds the execute stored procedure operation.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <param name="configType">The serialization configuration type identifiers.</param>
                /// <param name="serializationKind">The <see cref="SerializationKind"/>.</param>
                /// <param name="serializationFormat">The <see cref="SerializationFormat"/>.</param>
                /// <param name="compressionKind">The <see cref="CompressionKind"/>.</param>
                /// <param name="unregisteredTypeEncounteredStrategy">The <see cref="UnregisteredTypeEncounteredStrategy"/>.</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName,
                    IdentifiedType configType,
                    SerializationKind serializationKind,
                    SerializationFormat serializationFormat,
                    CompressionKind compressionKind,
                    UnregisteredTypeEncounteredStrategy unregisteredTypeEncounteredStrategy)
                {
                    var sprocName = Invariant($"[{streamName}].[{nameof(GetIdAddIfNecessarySerializerRepresentation)}]");

                    var parameters = new List <ParameterDefinitionBase>()
                    {
                        new InputParameterDefinition <int>(nameof(InputParamName.ConfigTypeWithoutVersionId), Tables.TypeWithoutVersion.Id.SqlDataType, configType.IdWithoutVersion),
                        new InputParameterDefinition <int>(nameof(InputParamName.ConfigTypeWithVersionId), Tables.TypeWithVersion.Id.SqlDataType, configType.IdWithVersion),
                        new InputParameterDefinition <string>(nameof(InputParamName.SerializationKind), Tables.SerializerRepresentation.SerializationKind.SqlDataType, serializationKind.ToString()),
                        new InputParameterDefinition <string>(nameof(InputParamName.SerializationFormat), Tables.SerializerRepresentation.SerializationFormat.SqlDataType, serializationFormat.ToString()),
                        new InputParameterDefinition <string>(nameof(InputParamName.CompressionKind), Tables.SerializerRepresentation.CompressionKind.SqlDataType, compressionKind.ToString()),
                        new InputParameterDefinition <string>(nameof(InputParamName.UnregisteredTypeEncounteredStrategy), Tables.SerializerRepresentation.SerializationKind.SqlDataType, unregisteredTypeEncounteredStrategy.ToString()),
                        new OutputParameterDefinition <int>(nameof(OutputParamName.Id), Tables.SerializerRepresentation.Id.SqlDataType),
                    };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return(result);
                }
Example #2
0
                /// <summary>
                /// Builds the execute stored procedure operation.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <param name="serializerRepresentation">The serializer representation.</param>
                /// <param name="identifierType">The identifier type.</param>
                /// <param name="objectType">The object type.</param>
                /// <param name="internalRecordId">The optional internal record identifier (for stream re-play).</param>
                /// <param name="serializedObjectId">The serialized object identifier.</param>
                /// <param name="serializedObjectString">The serialized object as a string (should have data IFF the serializer is set to SerializationFormat.String, otherwise null).</param>
                /// <param name="serializedObjectBytes">The serialized object as a byte array (should have data IFF the serializer is set to SerializationFormat.Binary, otherwise null).</param>
                /// <param name="objectDateTimeUtc">The date time of the object if exists.</param>
                /// <param name="tagIdsCsv">The tag identifiers as CSV.</param>
                /// <param name="existingRecordStrategy">Existing record encountered strategy.</param>
                /// <param name="recordRetentionCount">Number of records to keep if using a pruning <paramref name="existingRecordStrategy"/>.</param>
                /// <param name="versionMatchStrategy">Type version match strategy.</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName,
                    IdentifiedSerializerRepresentation serializerRepresentation,
                    IdentifiedType identifierType,
                    IdentifiedType objectType,
                    long?internalRecordId,
                    string serializedObjectId,
                    string serializedObjectString,
                    byte[] serializedObjectBytes,
                    DateTime?objectDateTimeUtc,
                    string tagIdsCsv,
                    ExistingRecordStrategy existingRecordStrategy,
                    int?recordRetentionCount,
                    VersionMatchStrategy versionMatchStrategy)
                {
                    var sprocName = Invariant($"[{streamName}].{nameof(PutRecord)}");

                    var parameters = new List <ParameterDefinitionBase>()
                    {
                        new InputParameterDefinition <int>(nameof(InputParamName.SerializerRepresentationId), Tables.SerializerRepresentation.Id.SqlDataType, serializerRepresentation.Id),
                        new InputParameterDefinition <int?>(nameof(InputParamName.IdentifierTypeWithoutVersionId), Tables.TypeWithoutVersion.Id.SqlDataType, identifierType?.IdWithoutVersion),
                        new InputParameterDefinition <int?>(nameof(InputParamName.IdentifierTypeWithVersionId), Tables.TypeWithVersion.Id.SqlDataType, identifierType?.IdWithVersion),
                        new InputParameterDefinition <int?>(nameof(InputParamName.ObjectTypeWithoutVersionId), Tables.TypeWithoutVersion.Id.SqlDataType, objectType?.IdWithoutVersion),
                        new InputParameterDefinition <int?>(nameof(InputParamName.ObjectTypeWithVersionId), Tables.TypeWithVersion.Id.SqlDataType, objectType?.IdWithVersion),
                        new InputParameterDefinition <long?>(nameof(InputParamName.InternalRecordId), Tables.Record.Id.SqlDataType, internalRecordId),
                        new InputParameterDefinition <string>(nameof(InputParamName.StringSerializedId), Tables.Record.StringSerializedId.SqlDataType, serializedObjectId),
                        new InputParameterDefinition <string>(nameof(InputParamName.StringSerializedObject), Tables.Record.StringSerializedObject.SqlDataType, serializedObjectString),
                        new InputParameterDefinition <byte[]>(nameof(InputParamName.BinarySerializedObject), Tables.Record.BinarySerializedObject.SqlDataType, serializedObjectBytes),
                        new InputParameterDefinition <DateTime?>(nameof(InputParamName.ObjectDateTimeUtc), Tables.Record.ObjectDateTimeUtc.SqlDataType, objectDateTimeUtc),
                        new InputParameterDefinition <string>(nameof(InputParamName.TagIdsCsv), Tables.Record.TagIdsCsv.SqlDataType, tagIdsCsv),
                        new InputParameterDefinition <ExistingRecordStrategy>(nameof(InputParamName.ExistingRecordStrategy), new StringSqlDataTypeRepresentation(false, 50), existingRecordStrategy),
                        new InputParameterDefinition <int?>(nameof(InputParamName.RecordRetentionCount), new IntSqlDataTypeRepresentation(), recordRetentionCount),
                        new InputParameterDefinition <VersionMatchStrategy>(nameof(InputParamName.VersionMatchStrategy), new StringSqlDataTypeRepresentation(false, 50), versionMatchStrategy),
                        new OutputParameterDefinition <long?>(nameof(OutputParamName.Id), Tables.Record.Id.SqlDataType),
                        new OutputParameterDefinition <string>(nameof(OutputParamName.ExistingRecordIdsCsv), Tables.Record.TagIdsCsv.SqlDataType),
                        new OutputParameterDefinition <string>(nameof(OutputParamName.PrunedRecordIdsCsv), Tables.Record.TagIdsCsv.SqlDataType),
                    };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return(result);
                }