Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#if NET

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
Expand Down Expand Up @@ -223,6 +224,10 @@ private void SetupBatchCommandExecute()
{
throw ADP.ConnectionRequired(nameof(SetupBatchCommandExecute));
}
if (_commands is null)
{
throw ADP.InvalidOperation(StringsHelper.GetString(Strings.ADP_NoSqlBatchCommandList));
}
_batchCommand.Connection = Connection;
_batchCommand.Transaction = Transaction;
_batchCommand.SetBatchRPCMode(true, _commands.Count);
Expand Down
13 changes: 12 additions & 1 deletion src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Microsoft.Data.SqlClient/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4740,4 +4740,7 @@
<data name="ADP_ColumnSchemaMissing1" xml:space="preserve">
<value>Missing the DataColumn '{0}' for the SourceColumn '{2}'.</value>
</data>
<data name="ADP_NoSqlBatchCommandList" xml:space="preserve">
<value>SqlBatchCommand list has not been initialized.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ public static void MissingCommandTextThrows()
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
public static async Task MissingCommandsThrows()
{
using (var connection = new SqlConnection(DataTestUtility.TCPConnectionString))
using (var batch = new SqlBatch { Connection = connection })
{
connection.Open();
await Assert.ThrowsAsync<InvalidOperationException>(() => batch.ExecuteReaderAsync());
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
public static void MissingConnectionThrows()
{
Expand Down
Loading