@@ -43,7 +43,8 @@ type private CommandBatchBuilder(conn : DbConnection, tran : DbTransaction) =
4343 j <- j + 1
4444 | ScalarParameter( parameterType, o) ->
4545 addParam ( parameterName ( parameterOffset + i)) parameterType o
46- for fragment in command.Fragments do
46+ | RawSQLParameter _ -> ()
47+ let rec addFragment fragment =
4748 let fragmentString =
4849 match fragment with
4950 | LocalName name -> localName commandIndex name
@@ -57,6 +58,10 @@ type private CommandBatchBuilder(conn : DbConnection, tran : DbTransaction) =
5758 }
5859 " (" + String.concat " ," parNames + " )"
5960 | ScalarParameter _ -> parameterName ( parameterOffset + i)
61+ | RawSQLParameter frags ->
62+ for frag in frags do
63+ addFragment frag
64+ " "
6065 | InlineParameter ( dbType, value) ->
6166 let name = dynamicParameterName dbCommand.Parameters.Count
6267 addParam name dbType value
@@ -65,6 +70,8 @@ type private CommandBatchBuilder(conn : DbConnection, tran : DbTransaction) =
6570 | Whitespace -> " "
6671 | LineBreak -> " \n "
6772 ignore <| builder.Append( fragmentString)
73+ for fragment in command.Fragments do
74+ addFragment fragment
6875 match command.ResultSetCount with
6976 | Some _ -> () // no need to add terminator statement
7077 | None when commandIndex + 1 >= commands.Count -> ()
@@ -78,12 +85,22 @@ type private CommandBatchBuilder(conn : DbConnection, tran : DbTransaction) =
7885 dbCommand.CommandText <- builder.ToString()
7986
8087 member __.BatchCommand ( cmd : Command ) =
81- let mutable count = 0
88+ let countInlineParameters fragments =
89+ let mutable i = 0
90+ for fragment in fragments do
91+ match fragment with
92+ | InlineParameter _ -> i <- i + 1
93+ | _ -> ()
94+ i
95+
96+ let mutable count = countInlineParameters cmd.Fragments
8297 for par in cmd.Parameters do
8398 count <- count +
8499 match par with
85100 | ListParameter (_, os) -> os.Length
86101 | ScalarParameter _ -> 1
102+ | RawSQLParameter frags -> countInlineParameters frags
103+
87104 if parameterCount + count > maxParameters then
88105 Nullable()
89106 else
0 commit comments