Show / Hide Table of Contents

Class SqlBatchWriter

Class for building a large string of SQL which will be sent to the database in batches for execution using the ApplySQL action

Inheritance
System.Object
SqlBatchWriter
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: Innovator.Client
Assembly: Innovator.Client.dll
Syntax
public class SqlBatchWriter : IDisposable
Examples

For an example of inserting multiple records into the database, consider the following

var sql = new SqlBatchWriter(conn);
for (var i = 0; i < 30000; i++)
{
  sql.Command("insert into innovator._numbers (num) values (@0)", i);
}

Constructors

| Improve this Doc View Source

SqlBatchWriter(IConnection)

Instantiate the writer with a connection

Declaration
public SqlBatchWriter(IConnection conn)
Parameters
Type Name Description
IConnection conn

Server connection

| Improve this Doc View Source

SqlBatchWriter(IConnection, Int32)

Instantiate the writer with a connection and an initial capacity for the internal System.Text.StringBuilder

Declaration
public SqlBatchWriter(IConnection conn, int capacity)
Parameters
Type Name Description
IConnection conn

Server connection

System.Int32 capacity

System.Text.StringBuilder initial capacity

Properties

| Improve this Doc View Source

Threshold

Nuumber of commands at which to send the query to the database

Declaration
public int Threshold { get; set; }
Property Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

Command()

Append a new line (empty command) to the SQL

Declaration
public SqlBatchWriter Command()
Returns
Type Description
SqlBatchWriter
Remarks

Depending on the number of commands written and the Threshold, the buffer of SQL commands might be sent to the server after this call

| Improve this Doc View Source

Command(String)

Append the specified command to the SQL

Declaration
public SqlBatchWriter Command(string value)
Parameters
Type Name Description
System.String value

SQL command to execute

Returns
Type Description
SqlBatchWriter
Remarks

Depending on the number of commands written and the Threshold, the buffer of SQL commands might be sent to the server after this call

| Improve this Doc View Source

Command(String, Object[])

Append the specified command with parameters the SQL. @# (e.g. @0) style parameters are replaced

Declaration
public SqlBatchWriter Command(string format, params object[] args)
Parameters
Type Name Description
System.String format
System.Object[] args
Returns
Type Description
SqlBatchWriter
Remarks

Depending on the number of commands written and the Threshold, the buffer of SQL commands might be sent to the server after this call. See Command and ParameterSubstitution for more information on how parameters are substituted

| Improve this Doc View Source

Dispose()

Send the current buffer to the database

Declaration
public void Dispose()
Implements
System.IDisposable.Dispose()
| Improve this Doc View Source

Flush()

Send the current buffer to the database

Declaration
public void Flush()
| Improve this Doc View Source

Part(String)

Append a part of a command to the SQL

Declaration
public SqlBatchWriter Part(string value)
Parameters
Type Name Description
System.String value
Returns
Type Description
SqlBatchWriter
Remarks

No SQL will be sent to the server until the SQL "part" has been finished with a call to Command() (or one of the overloads)

| Improve this Doc View Source

Part(String, Object[])

Append the specified command with parameters the SQL. @# (e.g. @0) style parameters are replaced

Declaration
public SqlBatchWriter Part(string format, params object[] args)
Parameters
Type Name Description
System.String format
System.Object[] args
Returns
Type Description
SqlBatchWriter
Remarks

No SQL will be sent to the server until the SQL "part" has been finished with a call to Command() (or one of the overloads). See Command and ParameterSubstitution for more information on how parameters are substituted

| Improve this Doc View Source

ToString()

Render the current buffer to a string

Declaration
public override string ToString()
Returns
Type Description
System.String
Overrides
System.Object.ToString()
  • Improve this Doc
  • View Source
Back to top Copyright © 2015-2017 Microsoft
Generated by DocFX