Show / Hide Table of Contents

# Class Batch

This class represents a batch within a query

##### Inheritance

System.Object
Batch

##### 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)
System.Object.ToString()

###### Namespace:Microsoft.SqlTools.ServiceLayer.QueryExecution

###### Assembly:Microsoft.SqlTools.ServiceLayer.dll

##### Syntax

    public class Batch : IDisposable

### Properties

| Improve this Doc View Source

#### BatchText

The text of batch that will be executed

##### Declaration

    public string BatchText { get; set; }

##### Property Value

Type | Description
--- | ---
System.String |

| Improve this Doc View Source

#### ExecutionElapsedTime

Localized timestamp for how long it took for the execution to complete

##### Declaration

    public string ExecutionElapsedTime { get; }

##### Property Value

Type | Description
--- | ---
System.String |

| Improve this Doc View Source

#### ExecutionEndTimeStamp

Localized timestamp for when the execution completed. Stored in UTC ISO 8601 format; should be localized before displaying to any user

##### Declaration

    public string ExecutionEndTimeStamp { get; }

##### Property Value

Type | Description
--- | ---
System.String |

| Improve this Doc View Source

#### ExecutionStartTimeStamp

Localized timestamp for when the execution began. Stored in UTC ISO 8601 format; should be localized before displaying to any user

##### Declaration

    public string ExecutionStartTimeStamp { get; }

##### Property Value

Type | Description
--- | ---
System.String |

| Improve this Doc View Source

#### HasError

Whether or not this batch has an error

##### Declaration

    public bool HasError { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### HasExecuted

Whether or not this batch has been executed, regardless of success or failure

##### Declaration

    public bool HasExecuted { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### Id

Ordinal of the batch in the query

##### Declaration

    public int Id { get; }

##### Property Value

Type | Description
--- | ---
System.Int32 |

| Improve this Doc View Source

#### ResultMessages

Messages that have come back from the server

##### Declaration

    public IEnumerable<ResultMessage> ResultMessages { get; }

##### Property Value

Type | Description
--- | ---
System.Collections.Generic.IEnumerable<ResultMessage> |

| Improve this Doc View Source

#### ResultSets

The result sets of the batch execution

##### Declaration

    public IList<ResultSet> ResultSets { get; }

##### Property Value

Type | Description
--- | ---
System.Collections.Generic.IList<ResultSet> |

| Improve this Doc View Source

#### ResultSummaries

Property for generating a set result set summaries from the result sets

##### Declaration

    public ResultSetSummary[] ResultSummaries { get; }

##### Property Value

Type | Description
--- | ---
ResultSetSummary[] |

| Improve this Doc View Source

#### Summary

Creates a BatchSummary based on the batch instance

##### Declaration

    public BatchSummary Summary { get; }

##### Property Value

Type | Description
--- | ---
BatchSummary |

### Methods

| Improve this Doc View Source

#### Dispose()

##### Declaration

    public void Dispose()

##### Implements

System.IDisposable.Dispose()
| Improve this Doc View Source

#### Dispose(Boolean)

##### Declaration

    protected virtual void Dispose(bool disposing)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Boolean | disposing |

| Improve this Doc View Source

#### Execute(DbConnection, CancellationToken)

Executes this batch and captures any server messages that are returned.

##### Declaration

    public Task Execute(DbConnection conn, CancellationToken cancellationToken)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Data.Common.DbConnection | conn | The connection to use to execute the batch
System.Threading.CancellationToken | cancellationToken | Token for cancelling the execution

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task |

| Improve this Doc View Source

#### GetSubset(Int32, Int32, Int32)

Generates a subset of the rows from a result set of the batch

##### Declaration

    public Task<ResultSetSubset> GetSubset(int resultSetIndex, int startRow, int rowCount)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | resultSetIndex | The index for selecting the result set
System.Int32 | startRow | The starting row of the results
System.Int32 | rowCount | How many rows to retrieve

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<ResultSetSubset> | A subset of results

### Events

| Improve this Doc View Source

#### BatchCompletion

Event that will be called when the batch has completed execution

##### Declaration

    public event Batch.BatchAsyncEventHandler BatchCompletion

##### Event Type

Type | Description
--- | ---
Batch.BatchAsyncEventHandler |

| Improve this Doc View Source

#### BatchStart

Event to call when the batch has started execution

##### Declaration

    public event Batch.BatchAsyncEventHandler BatchStart

##### Event Type

Type | Description
--- | ---
Batch.BatchAsyncEventHandler |

| Improve this Doc View Source

#### ResultSetCompletion

Event that will be called when the resultset has completed execution. It will not be called from the Batch but from the ResultSet instance

##### Declaration

    public event ResultSet.ResultSetAsyncEventHandler ResultSetCompletion

##### Event Type

Type | Description
--- | ---
ResultSet.ResultSetAsyncEventHandler |