/// <summary> /// Builds the execute stored procedure op. /// </summary> /// <param name="streamName">Name of the stream.</param> /// <param name="concern">The concern.</param> /// <param name="details">The details.</param> /// <param name="convertedRecordFilter">Converted form of <see cref="RecordFilter"/>.</param> /// <param name="tagIdsForEntryCsv">The tag identifiers of tags to add to new entries.</param> /// <param name="orderRecordsBy">The order records strategy.</param> /// <param name="minimumInternalRecordId">The optional minimum internal record identifier, null for default.</param> /// <param name="inheritRecordTags">The tags on the record should also be on the handling entry.</param> /// <param name="streamRecordItemsToInclude">The items to include.</param> /// <returns>Operation to execute stored procedure.</returns> public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp( string streamName, string concern, string details, RecordFilterConvertedForStoredProcedure convertedRecordFilter, string tagIdsForEntryCsv, OrderRecordsBy orderRecordsBy, long?minimumInternalRecordId, bool inheritRecordTags, StreamRecordItemsToInclude streamRecordItemsToInclude) { streamRecordItemsToInclude .MustForArg(nameof(streamRecordItemsToInclude)) .BeElementIn( new[] { StreamRecordItemsToInclude.MetadataAndPayload, StreamRecordItemsToInclude.MetadataOnly, }); var sprocName = Invariant($"[{streamName}].{nameof(TryHandleRecord)}"); var parameters = new List <ParameterDefinitionBase>() { new InputParameterDefinition <string>( nameof(InputParamName.Concern), Tables.Handling.Concern.SqlDataType, concern), new InputParameterDefinition <string>( nameof(InputParamName.Details), Tables.Handling.Details.SqlDataType, details), new InputParameterDefinition <string>( nameof(InputParamName.InternalRecordIdsCsv), new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant), convertedRecordFilter.InternalRecordIdsCsv), new InputParameterDefinition <string>( nameof(InputParamName.IdentifierTypeIdsCsv), new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant), convertedRecordFilter.IdentifierTypeIdsCsv), new InputParameterDefinition <string>( nameof(InputParamName.ObjectTypeIdsCsv), new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant), convertedRecordFilter.ObjectTypeIdsCsv), new InputParameterDefinition <string>( nameof(InputParamName.StringIdentifiersXml), new XmlSqlDataTypeRepresentation(), convertedRecordFilter.StringIdsToMatchXml), new InputParameterDefinition <string>( nameof(InputParamName.TagIdsToMatchCsv), new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant), convertedRecordFilter.TagIdsCsv), new InputParameterDefinition <string>( nameof(InputParamName.TagMatchStrategy), new StringSqlDataTypeRepresentation(false, 40), convertedRecordFilter.TagMatchStrategy.ToString()), new InputParameterDefinition <string>( nameof(InputParamName.VersionMatchStrategy), new StringSqlDataTypeRepresentation(false, 20), convertedRecordFilter.VersionMatchStrategy.ToString()), new InputParameterDefinition <string>( nameof(InputParamName.DeprecatedIdEventTypeIdsCsv), new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant), convertedRecordFilter.DeprecatedIdEventTypeIdsCsv), new InputParameterDefinition <string>( nameof(InputParamName.TagIdsForEntryCsv), Tables.Record.TagIdsCsv.SqlDataType, tagIdsForEntryCsv), new InputParameterDefinition <string>( nameof(InputParamName.OrderRecordsBy), new StringSqlDataTypeRepresentation(false, 50), orderRecordsBy.ToString()), new InputParameterDefinition <int>( nameof(InputParamName.InheritRecordTags), new IntSqlDataTypeRepresentation(), inheritRecordTags ? 1 : 0), new InputParameterDefinition <long?>( nameof(InputParamName.MinimumInternalRecordId), Tables.Record.Id.SqlDataType, minimumInternalRecordId), new InputParameterDefinition <int>( nameof(InputParamName.IncludePayload), new IntSqlDataTypeRepresentation(), streamRecordItemsToInclude == StreamRecordItemsToInclude.MetadataAndPayload ? 1 : 0), new OutputParameterDefinition <int>(nameof(OutputParamName.ShouldHandle), new IntSqlDataTypeRepresentation()), new OutputParameterDefinition <int>(nameof(OutputParamName.IsBlocked), new IntSqlDataTypeRepresentation()), new OutputParameterDefinition <long>(nameof(OutputParamName.Id), Tables.Handling.Id.SqlDataType), new OutputParameterDefinition <long>(nameof(OutputParamName.InternalRecordId), Tables.Record.Id.SqlDataType), new OutputParameterDefinition <int>( nameof(OutputParamName.SerializerRepresentationId), Tables.SerializerRepresentation.Id.SqlDataType), new OutputParameterDefinition <int>( nameof(OutputParamName.IdentifierTypeWithVersionId), Tables.TypeWithVersion.Id.SqlDataType), new OutputParameterDefinition <int>( nameof(OutputParamName.ObjectTypeWithVersionId), Tables.TypeWithVersion.Id.SqlDataType), new OutputParameterDefinition <string>( nameof(OutputParamName.StringSerializedId), Tables.Record.StringSerializedId.SqlDataType), new OutputParameterDefinition <string>( nameof(OutputParamName.StringSerializedObject), Tables.Record.StringSerializedObject.SqlDataType), new OutputParameterDefinition <byte[]>( nameof(OutputParamName.BinarySerializedObject), Tables.Record.BinarySerializedObject.SqlDataType), new OutputParameterDefinition <DateTime>( nameof(OutputParamName.RecordDateTime), Tables.Record.RecordCreatedUtc.SqlDataType), new OutputParameterDefinition <DateTime?>( nameof(OutputParamName.ObjectDateTime), Tables.Record.ObjectDateTimeUtc.SqlDataType), new OutputParameterDefinition <string>( nameof(OutputParamName.TagIdsCsv), Tables.Record.TagIdsCsv.SqlDataType), }; var result = new ExecuteStoredProcedureOp(sprocName, parameters); return(result); }
/// <summary> /// Builds the execute stored procedure operation. /// </summary> /// <param name="streamName">Name of the stream.</param> /// <param name="convertedRecordFilter">Converted form of <see cref="RecordFilter"/>.</param> /// <param name="streamRecordItemsToInclude">The items to include.</param> /// <returns>Operation to execute stored procedure.</returns> public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp( string streamName, RecordFilterConvertedForStoredProcedure convertedRecordFilter, StreamRecordItemsToInclude streamRecordItemsToInclude) { streamRecordItemsToInclude .MustForArg(nameof(streamRecordItemsToInclude)) .BeElementIn( new[] { StreamRecordItemsToInclude.MetadataAndPayload, StreamRecordItemsToInclude.MetadataOnly, }); var sprocName = Invariant($"[{streamName}].[{nameof(GetLatestRecord)}]"); var parameters = new List <ParameterDefinitionBase>() { new InputParameterDefinition <string>( nameof(InputParamName.InternalRecordIdsCsv), new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant), convertedRecordFilter.InternalRecordIdsCsv), new InputParameterDefinition <string>( nameof(InputParamName.IdentifierTypeIdsCsv), new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant), convertedRecordFilter.IdentifierTypeIdsCsv), new InputParameterDefinition <string>( nameof(InputParamName.ObjectTypeIdsCsv), new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant), convertedRecordFilter.ObjectTypeIdsCsv), new InputParameterDefinition <string>( nameof(InputParamName.StringIdentifiersXml), new XmlSqlDataTypeRepresentation(), convertedRecordFilter.StringIdsToMatchXml), new InputParameterDefinition <string>( nameof(InputParamName.TagIdsToMatchCsv), new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant), convertedRecordFilter.TagIdsCsv), new InputParameterDefinition <string>( nameof(InputParamName.TagMatchStrategy), new StringSqlDataTypeRepresentation(false, 40), convertedRecordFilter.TagMatchStrategy.ToString()), new InputParameterDefinition <string>( nameof(InputParamName.VersionMatchStrategy), new StringSqlDataTypeRepresentation(false, 20), convertedRecordFilter.VersionMatchStrategy.ToString()), new InputParameterDefinition <string>( nameof(InputParamName.DeprecatedIdEventTypeIdsCsv), new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant), convertedRecordFilter.DeprecatedIdEventTypeIdsCsv), new InputParameterDefinition <int>( nameof(InputParamName.IncludePayload), new IntSqlDataTypeRepresentation(), streamRecordItemsToInclude == StreamRecordItemsToInclude.MetadataAndPayload ? 1 : 0), new OutputParameterDefinition <long>(nameof(OutputParamName.InternalRecordId), Tables.Record.Id.SqlDataType), new OutputParameterDefinition <int>( nameof(OutputParamName.SerializerRepresentationId), Tables.SerializerRepresentation.Id.SqlDataType), new OutputParameterDefinition <int>( nameof(OutputParamName.IdentifierTypeWithVersionId), Tables.TypeWithVersion.Id.SqlDataType), new OutputParameterDefinition <int>( nameof(OutputParamName.ObjectTypeWithVersionId), Tables.TypeWithVersion.Id.SqlDataType), new OutputParameterDefinition <string>( nameof(OutputParamName.StringSerializedId), Tables.Record.StringSerializedId.SqlDataType), new OutputParameterDefinition <string>( nameof(OutputParamName.StringSerializedObject), Tables.Record.StringSerializedObject.SqlDataType), new OutputParameterDefinition <byte[]>( nameof(OutputParamName.BinarySerializedObject), Tables.Record.BinarySerializedObject.SqlDataType), new OutputParameterDefinition <DateTime>( nameof(OutputParamName.RecordDateTime), Tables.Record.RecordCreatedUtc.SqlDataType), new OutputParameterDefinition <DateTime?>( nameof(OutputParamName.ObjectDateTime), Tables.Record.ObjectDateTimeUtc.SqlDataType), new OutputParameterDefinition <string>( nameof(OutputParamName.TagIdsCsv), Tables.Record.TagIdsCsv.SqlDataType), }; var result = new ExecuteStoredProcedureOp(sprocName, parameters); return(result); }