1
- #nullable disable
2
1
using System ;
3
2
using System . Collections . Generic ;
4
3
using System . Data ;
@@ -18,7 +17,7 @@ internal sealed class SingleCommandPayloadCreator : ICommandPayloadCreator
18
17
// with this as the first column name, the result set will be treated as 'out' parameters for the previous command.
19
18
public static string OutParameterSentinelColumnName => "\uE001 \b \x0B " ;
20
19
21
- public bool WriteQueryCommand ( ref CommandListPosition commandListPosition , IDictionary < string , CachedProcedure > cachedProcedures , ByteBufferWriter writer )
20
+ public bool WriteQueryCommand ( ref CommandListPosition commandListPosition , IDictionary < string , CachedProcedure ? > cachedProcedures , ByteBufferWriter writer )
22
21
{
23
22
if ( commandListPosition . CommandIndex == commandListPosition . Commands . Count )
24
23
return false ;
@@ -28,7 +27,7 @@ public bool WriteQueryCommand(ref CommandListPosition commandListPosition, IDict
28
27
if ( preparedStatements is null )
29
28
{
30
29
if ( Log . IsDebugEnabled ( ) )
31
- Log . Debug ( "Session{0} Preparing command payload; CommandText: {1}" , command . Connection . Session . Id , command . CommandText ) ;
30
+ Log . Debug ( "Session{0} Preparing command payload; CommandText: {1}" , command . Connection ! . Session . Id , command . CommandText ) ;
32
31
33
32
writer . Write ( ( byte ) CommandKind . Query ) ;
34
33
WriteQueryPayload ( command , cachedProcedures , writer ) ;
@@ -57,15 +56,15 @@ public bool WriteQueryCommand(ref CommandListPosition commandListPosition, IDict
57
56
/// <param name="cachedProcedures">The cached procedures.</param>
58
57
/// <param name="writer">The output writer.</param>
59
58
/// <returns><c>true</c> if a complete command was written; otherwise, <c>false</c>.</returns>
60
- public static bool WriteQueryPayload ( IMySqlCommand command , IDictionary < string , CachedProcedure > cachedProcedures , ByteBufferWriter writer ) =>
59
+ public static bool WriteQueryPayload ( IMySqlCommand command , IDictionary < string , CachedProcedure ? > cachedProcedures , ByteBufferWriter writer ) =>
61
60
( command . CommandType == CommandType . StoredProcedure ) ? WriteStoredProcedure ( command , cachedProcedures , writer ) : WriteCommand ( command , writer ) ;
62
61
63
62
private static void WritePreparedStatement ( IMySqlCommand command , PreparedStatement preparedStatement , ByteBufferWriter writer )
64
63
{
65
64
var parameterCollection = command . RawParameters ;
66
65
67
66
if ( Log . IsDebugEnabled ( ) )
68
- Log . Debug ( "Session{0} Preparing command payload; CommandId: {1}; CommandText: {2}" , command . Connection . Session . Id , preparedStatement . StatementId , command . CommandText ) ;
67
+ Log . Debug ( "Session{0} Preparing command payload; CommandId: {1}; CommandText: {2}" , command . Connection ! . Session . Id , preparedStatement . StatementId , command . CommandText ) ;
69
68
70
69
writer . Write ( preparedStatement . StatementId ) ;
71
70
writer . Write ( ( byte ) 0 ) ;
@@ -84,7 +83,7 @@ private static void WritePreparedStatement(IMySqlCommand command, PreparedStatem
84
83
throw new MySqlException ( "Parameter '{0}' must be defined." . FormatInvariant ( parameterName ) ) ;
85
84
else if ( parameterIndex < 0 || parameterIndex >= ( parameterCollection ? . Count ?? 0 ) )
86
85
throw new MySqlException ( "Parameter index {0} is invalid when only {1} parameter{2} defined." . FormatInvariant ( parameterIndex , parameterCollection ? . Count ?? 0 , parameterCollection ? . Count == 1 ? " is" : "s are" ) ) ;
87
- parameters [ i ] = parameterCollection [ parameterIndex ] ;
86
+ parameters [ i ] = parameterCollection ! [ parameterIndex ] ;
88
87
}
89
88
90
89
// write null bitmap
@@ -118,7 +117,7 @@ private static void WritePreparedStatement(IMySqlCommand command, PreparedStatem
118
117
mySqlDbType = TypeMapper . Instance . GetMySqlDbTypeForDbType ( dbType ) ;
119
118
}
120
119
121
- writer . Write ( TypeMapper . ConvertToColumnTypeAndFlags ( mySqlDbType , command . Connection . GuidFormat ) ) ;
120
+ writer . Write ( TypeMapper . ConvertToColumnTypeAndFlags ( mySqlDbType , command . Connection ! . GuidFormat ) ) ;
122
121
}
123
122
124
123
var options = command . CreateStatementPreparerOptions ( ) ;
@@ -127,22 +126,22 @@ private static void WritePreparedStatement(IMySqlCommand command, PreparedStatem
127
126
}
128
127
}
129
128
130
- private static bool WriteStoredProcedure ( IMySqlCommand command , IDictionary < string , CachedProcedure > cachedProcedures , ByteBufferWriter writer )
129
+ private static bool WriteStoredProcedure ( IMySqlCommand command , IDictionary < string , CachedProcedure ? > cachedProcedures , ByteBufferWriter writer )
131
130
{
132
131
var parameterCollection = command . RawParameters ;
133
- var cachedProcedure = cachedProcedures [ command . CommandText ] ;
132
+ var cachedProcedure = cachedProcedures [ command . CommandText ! ] ;
134
133
if ( cachedProcedure is object )
135
134
parameterCollection = cachedProcedure . AlignParamsWithDb ( parameterCollection ) ;
136
135
137
- MySqlParameter returnParameter = null ;
136
+ MySqlParameter ? returnParameter = null ;
138
137
var outParameters = new MySqlParameterCollection ( ) ;
139
138
var outParameterNames = new List < string > ( ) ;
140
139
var inParameters = new MySqlParameterCollection ( ) ;
141
140
var argParameterNames = new List < string > ( ) ;
142
141
var inOutSetParameters = "" ;
143
142
for ( var i = 0 ; i < ( parameterCollection ? . Count ?? 0 ) ; i ++ )
144
143
{
145
- var param = parameterCollection [ i ] ;
144
+ var param = parameterCollection ! [ i ] ;
146
145
var inName = "@inParam" + i ;
147
146
var outName = "@outParam" + i ;
148
147
switch ( param . Direction )
0 commit comments