Show / Hide Table of Contents

# Class Query

Internal representation of an active query

##### Inheritance

System.Object
Query

##### 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 Query : IDisposable

### Constructors

| Improve this Doc View Source

#### Query(String, ConnectionInfo, QueryExecutionSettings, IFileStreamFactory)

Constructor for a query

##### Declaration

    public Query(string queryText, ConnectionInfo connection, QueryExecutionSettings settings, IFileStreamFactory outputFactory)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | queryText | The text of the query to execute
ConnectionInfo | connection | The information of the connection to use to execute the query
QueryExecutionSettings | settings | Settings for how to execute the query, from the user
IFileStreamFactory | outputFactory | Factory for creating output files

### Properties

| Improve this Doc View Source

#### BatchSummaries

The summaries of the batches underneath this query

##### Declaration

    public BatchSummary[] BatchSummaries { get; }

##### Property Value

Type | Description
--- | ---
BatchSummary[] |

| Improve this Doc View Source

#### HasExecuted

Whether or not the query has completed executed, regardless of success or failure

##### Declaration

    public bool HasExecuted { get; }

##### Property Value

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

##### Remarks

Don't touch the setter unless you're doing unit tests!

| Improve this Doc View Source

#### QueryText

The text of the query to execute

##### Declaration

    public string QueryText { get; set; }

##### Property Value

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

### Methods

| Improve this Doc View Source

#### Cancel()

Cancels the query by issuing the cancellation token

##### Declaration

    public void Cancel()

| 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()

##### Declaration

    public void Execute()

| Improve this Doc View Source

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

Retrieves a subset of the result sets

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | batchIndex | The index for selecting the batch item
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

#### BatchCompleted

Event to be called when a batch is completed.

##### Declaration

    public event Batch.BatchAsyncEventHandler BatchCompleted

##### Event Type

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

| Improve this Doc View Source

#### BatchStarted

Event to be called when a batch starts execution.

##### Declaration

    public event Batch.BatchAsyncEventHandler BatchStarted

##### Event Type

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

| Improve this Doc View Source

#### QueryCompleted

Callback for when the query has completed successfully

##### Declaration

    public event Query.QueryAsyncEventHandler QueryCompleted

##### Event Type

Type | Description
--- | ---
Query.QueryAsyncEventHandler |

| Improve this Doc View Source

#### QueryConnectionException

Callback for when the query connection has failed

##### Declaration

    public event Query.QueryAsyncErrorEventHandler QueryConnectionException

##### Event Type

Type | Description
--- | ---
Query.QueryAsyncErrorEventHandler |

| Improve this Doc View Source

#### QueryFailed

Callback for when the query has failed

##### Declaration

    public event Query.QueryAsyncEventHandler QueryFailed

##### Event Type

Type | Description
--- | ---
Query.QueryAsyncEventHandler |

| Improve this Doc View Source

#### ResultSetCompleted

Event to be called when a resultset has completed.

##### Declaration

    public event ResultSet.ResultSetAsyncEventHandler ResultSetCompleted

##### Event Type

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