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
Inherited Members
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 SourceSqlBatchWriter(IConnection)
Instantiate the writer with a connection
Declaration
public SqlBatchWriter(IConnection conn)
Parameters
Type | Name | Description |
---|---|---|
IConnection | conn | Server connection |
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 SourceThreshold
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 SourceCommand()
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
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
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
Dispose()
Send the current buffer to the database
Declaration
public void Dispose()
Implements
Flush()
Send the current buffer to the database
Declaration
public void Flush()
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)
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
ToString()
Render the current buffer to a string
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |