Mimer SQL Data Provider
MimerBatch Class
Members  Example 




Mimer.Data.Client Namespace : MimerBatch Class
Represents a batch of MimerBatchCommand which can be executed against a data source in a single round trip.
Object Model
MimerBatch Class
Syntax
'Declaration
 
Public NotInheritable Class MimerBatch 
   Inherits System.Data.Common.DbBatch
public sealed class MimerBatch : System.Data.Common.DbBatch 
public class MimerBatch = class(System.Data.Common.DbBatch)sealed; 
public sealed class MimerBatch extends System.Data.Common.DbBatch
public __gc __sealed class MimerBatch : public System.Data.Common.DbBatch 
Example
The following example demonstrates the use of the MimerBatch and MimerBatchCommand classes for batch processing in a database. It connects to a database and creates a batch to execute multiple SQL commands.The batch includes 10 insert commands with parameters, a select command, an update command to modify specific records, and another select command to view changes. The batch is executed using a reader, and the results are processed and displayed.
var connectionString = "Database=exampledb;protocol=tcp;node=dbnode;user id=devuser;password=devpass";
            
using var connection = new MimerConnection(connectionString);
            
using var batch = new MimerBatch(connection);
            
connection.Open();
            
var count = 10;
for (int i = 0; i < count; i++)
{
	var batchCommand = new MimerBatchCommand("insert into tab values(?,?)")
	{
		Parameters =
		{
			new MimerParameter("", i),
			new MimerParameter("", "foo")
		}
	};
            
	batch.BatchCommands.Add(batchCommand);
}
            
var select = new MimerBatchCommand("select c1, c2 from tab");
var update = new MimerBatchCommand("update tab set c2 = 'bar' where c2 = 'foo'");
            
batch.BatchCommands.Add(select, update, select);
            
var results = new List<string>();
using (var reader = batch.ExecuteReader())
{
	do
	{
		while (reader.Read())
		{
			results.Add($"{reader.GetInt32(0)}, {reader.GetString(1)}");
		}
	} while (reader.NextResult());
}
            
foreach (var result in results)
{
	Console.WriteLine(result);
}
Inheritance Hierarchy

System.Object
   System.Data.Common.DbBatch
      Mimer.Data.Client.MimerBatch

Requirements
.NET 6 or later
See Also

Reference

MimerBatch Members
Mimer.Data.Client Namespace