Udostępnij za pośrednictwem


DocumentClient.CreateDocumentQuery Method

Definition

Overloads

CreateDocumentQuery(String, SqlQuerySpec, FeedOptions, Object)
Obsolete.

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement with parameterized values. It returns an IQueryable{dynamic}. For more information on preparing SQL statements with parameterized values, please see SqlQuerySpec.

CreateDocumentQuery(String, String, FeedOptions, Object)
Obsolete.

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement. It returns an IQueryable{dynamic}.

CreateDocumentQuery(Uri, String, FeedOptions)

Extension method to create a query for documents in the Azure Cosmos DB service.

CreateDocumentQuery(Uri, String, FeedOptions, Object)
Obsolete.

Extension method to create a query for documents in the Azure Cosmos DB service.

CreateDocumentQuery(Uri, SqlQuerySpec, FeedOptions, Object)
Obsolete.

Extension method to create a query for documents in the Azure Cosmos DB service.

CreateDocumentQuery(Uri, SqlQuerySpec, FeedOptions)

Extension method to create a query for documents in the Azure Cosmos DB service.

CreateDocumentQuery(String, String, FeedOptions)

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement. It returns an IQueryable{dynamic}.

CreateDocumentQuery(String, SqlQuerySpec, FeedOptions)

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement with parameterized values. It returns an IQueryable{dynamic}. For more information on preparing SQL statements with parameterized values, please see SqlQuerySpec.

CreateDocumentQuery(String, FeedOptions, Object)
Obsolete.

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB service. It returns IOrderedQueryable{Document}.

CreateDocumentQuery(Uri, FeedOptions)

Extension method to create a query for documents in the Azure Cosmos DB service.

CreateDocumentQuery(String, FeedOptions)

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB service. It returns IOrderedQueryable{Document}.

CreateDocumentQuery(Uri, FeedOptions, Object)
Obsolete.

Extension method to create a query for documents in the Azure Cosmos DB service.

CreateDocumentQuery<T>(Uri, SqlQuerySpec, FeedOptions)

Extension method to create a query for documents in the Azure Cosmos DB service.

CreateDocumentQuery<T>(Uri, String, FeedOptions, Object)
Obsolete.

Extension method to create a query for documents in the Azure Cosmos DB service.

CreateDocumentQuery<T>(Uri, SqlQuerySpec, FeedOptions, Object)
Obsolete.

Extension method to create a query for documents for the Azure Cosmos DB service.

CreateDocumentQuery<T>(String, String, FeedOptions, Object)
Obsolete.

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement. It returns an IQueryable{T}.

CreateDocumentQuery<T>(String, SqlQuerySpec, FeedOptions, Object)
Obsolete.

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement with parameterized values. It returns an IQueryable{T}. For more information on preparing SQL statements with parameterized values, please see SqlQuerySpec.

CreateDocumentQuery<T>(Uri, String, FeedOptions)

Extension method to create a query for documents in the Azure Cosmos DB service.

CreateDocumentQuery<T>(Uri, FeedOptions, Object)
Obsolete.

Extension method to create a query for documents in the Azure Cosmos DB service.

CreateDocumentQuery<T>(String, String, FeedOptions)

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement. It returns an IQueryable{T}.

CreateDocumentQuery<T>(String, SqlQuerySpec, FeedOptions)

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement with parameterized values. It returns an IQueryable{T}. For more information on preparing SQL statements with parameterized values, please see SqlQuerySpec.

CreateDocumentQuery<T>(String, FeedOptions, Object)
Obsolete.

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB service.

CreateDocumentQuery<T>(Uri, FeedOptions)

Extension method to create a query for documents in the Azure Cosmos DB service.

CreateDocumentQuery<T>(String, FeedOptions)

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB service.

CreateDocumentQuery(String, SqlQuerySpec, FeedOptions, Object)

Caution

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement with parameterized values. It returns an IQueryable{dynamic}. For more information on preparing SQL statements with parameterized values, please see SqlQuerySpec.

[System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")]
public System.Linq.IQueryable<dynamic> CreateDocumentQuery (string collectionLink, Microsoft.Azure.Documents.SqlQuerySpec querySpec, Microsoft.Azure.Documents.Client.FeedOptions feedOptions, object partitionKey);
[<System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")>]
member this.CreateDocumentQuery : string * Microsoft.Azure.Documents.SqlQuerySpec * Microsoft.Azure.Documents.Client.FeedOptions * obj -> System.Linq.IQueryable<obj>
Public Function CreateDocumentQuery (collectionLink As String, querySpec As SqlQuerySpec, feedOptions As FeedOptions, partitionKey As Object) As IQueryable(Of Object)

Parameters

collectionLink
String

The link to the parent document collection. Alternatively, this can be a path link to the database when using an IPartitionResolver, e.g. dbs/db_rid/

querySpec
SqlQuerySpec

The SqlQuerySpec instance containing the SQL expression.

feedOptions
FeedOptions

The options for processing the query result feed. For details, see FeedOptions

partitionKey
Object

The partition key that can be used with an IPartitionResolver.

Returns

an IQueryable{dynamic> that can evaluate the query.

Attributes

Remarks

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use Partitioned Collections for higher storage and throughput.

Applies to

CreateDocumentQuery(String, String, FeedOptions, Object)

Caution

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement. It returns an IQueryable{dynamic}.

[System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")]
public System.Linq.IQueryable<dynamic> CreateDocumentQuery (string collectionLink, string sqlExpression, Microsoft.Azure.Documents.Client.FeedOptions feedOptions, object partitionKey);
[<System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")>]
member this.CreateDocumentQuery : string * string * Microsoft.Azure.Documents.Client.FeedOptions * obj -> System.Linq.IQueryable<obj>
Public Function CreateDocumentQuery (collectionLink As String, sqlExpression As String, feedOptions As FeedOptions, partitionKey As Object) As IQueryable(Of Object)

Parameters

collectionLink
String

The link of the parent document collection. Alternatively, this can be a path link to the database when using an IPartitionResolver, e.g. dbs/db_rid/

sqlExpression
String

The SQL statement.

feedOptions
FeedOptions

The options for processing the query result feed. For details, see FeedOptions

partitionKey
Object

The partition key that can be used with an IPartitionResolver.

Returns

an IQueryable{dynamic> that can evaluate the query.

Attributes

Remarks

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use Partitioned Collections for higher storage and throughput.

Applies to

CreateDocumentQuery(Uri, String, FeedOptions)

Extension method to create a query for documents in the Azure Cosmos DB service.

public System.Linq.IQueryable<dynamic> CreateDocumentQuery (Uri documentCollectionOrDatabaseUri, string sqlExpression, Microsoft.Azure.Documents.Client.FeedOptions feedOptions = default);
abstract member CreateDocumentQuery : Uri * string * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<obj>
override this.CreateDocumentQuery : Uri * string * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<obj>
Public Function CreateDocumentQuery (documentCollectionOrDatabaseUri As Uri, sqlExpression As String, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of Object)

Parameters

documentCollectionOrDatabaseUri
Uri

The URI of the document collection.

sqlExpression
String

The sql query.

feedOptions
FeedOptions

The options for processing the query results feed.

Returns

The query result set.

Implements

Applies to

CreateDocumentQuery(Uri, String, FeedOptions, Object)

Caution

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.

Extension method to create a query for documents in the Azure Cosmos DB service.

[System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")]
public System.Linq.IQueryable<dynamic> CreateDocumentQuery (Uri documentCollectionOrDatabaseUri, string sqlExpression, Microsoft.Azure.Documents.Client.FeedOptions feedOptions, object partitionKey);
[<System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")>]
member this.CreateDocumentQuery : Uri * string * Microsoft.Azure.Documents.Client.FeedOptions * obj -> System.Linq.IQueryable<obj>
Public Function CreateDocumentQuery (documentCollectionOrDatabaseUri As Uri, sqlExpression As String, feedOptions As FeedOptions, partitionKey As Object) As IQueryable(Of Object)

Parameters

documentCollectionOrDatabaseUri
Uri

The URI of the document collection, e.g. dbs/db_rid/colls/coll_rid/. Alternatively, this can be a URI of the database when using an IPartitionResolver, e.g. dbs/db_rid/

sqlExpression
String

The sql query.

feedOptions
FeedOptions

The options for processing the query results feed.

partitionKey
Object

The partition key that can be used with an IPartitionResolver.

Returns

The query result set.

Attributes

Remarks

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use Partitioned Collections for higher storage and throughput.

Applies to

CreateDocumentQuery(Uri, SqlQuerySpec, FeedOptions, Object)

Caution

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.

Extension method to create a query for documents in the Azure Cosmos DB service.

[System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")]
public System.Linq.IQueryable<dynamic> CreateDocumentQuery (Uri documentCollectionOrDatabaseUri, Microsoft.Azure.Documents.SqlQuerySpec querySpec, Microsoft.Azure.Documents.Client.FeedOptions feedOptions, object partitionKey);
[<System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")>]
member this.CreateDocumentQuery : Uri * Microsoft.Azure.Documents.SqlQuerySpec * Microsoft.Azure.Documents.Client.FeedOptions * obj -> System.Linq.IQueryable<obj>
Public Function CreateDocumentQuery (documentCollectionOrDatabaseUri As Uri, querySpec As SqlQuerySpec, feedOptions As FeedOptions, partitionKey As Object) As IQueryable(Of Object)

Parameters

documentCollectionOrDatabaseUri
Uri

The URI of the document collection, e.g. dbs/db_rid/colls/coll_rid/. Alternatively, this can be a URI of the database when using an IPartitionResolver, e.g. dbs/db_rid/

querySpec
SqlQuerySpec

The sql query.

feedOptions
FeedOptions

The options for processing the query results feed.

partitionKey
Object

The partition key that can be used with an IPartitionResolver.

Returns

The query result set.

Attributes

Remarks

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use Partitioned Collections for higher storage and throughput.

Applies to

CreateDocumentQuery(Uri, SqlQuerySpec, FeedOptions)

Extension method to create a query for documents in the Azure Cosmos DB service.

public System.Linq.IQueryable<dynamic> CreateDocumentQuery (Uri documentCollectionOrDatabaseUri, Microsoft.Azure.Documents.SqlQuerySpec querySpec, Microsoft.Azure.Documents.Client.FeedOptions feedOptions = default);
abstract member CreateDocumentQuery : Uri * Microsoft.Azure.Documents.SqlQuerySpec * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<obj>
override this.CreateDocumentQuery : Uri * Microsoft.Azure.Documents.SqlQuerySpec * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<obj>
Public Function CreateDocumentQuery (documentCollectionOrDatabaseUri As Uri, querySpec As SqlQuerySpec, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of Object)

Parameters

documentCollectionOrDatabaseUri
Uri

The URI of the document collection.

querySpec
SqlQuerySpec

The sql query.

feedOptions
FeedOptions

The options for processing the query results feed.

Returns

The query result set.

Implements

Applies to

CreateDocumentQuery(String, String, FeedOptions)

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement. It returns an IQueryable{dynamic}.

public System.Linq.IQueryable<dynamic> CreateDocumentQuery (string collectionLink, string sqlExpression, Microsoft.Azure.Documents.Client.FeedOptions feedOptions = default);
abstract member CreateDocumentQuery : string * string * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<obj>
override this.CreateDocumentQuery : string * string * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<obj>
Public Function CreateDocumentQuery (collectionLink As String, sqlExpression As String, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of Object)

Parameters

collectionLink
String

The link to the parent document collection.

sqlExpression
String

The SQL statement.

feedOptions
FeedOptions

The options for processing the query result feed. For details, see FeedOptions

Returns

an IQueryable{dynamic> that can evaluate the query.

Implements

Examples

This example below queries for book documents.

// SQL querying allows dynamic property access
dynamic document = client.CreateDocumentQuery<dynamic>(collectionLink,
    "SELECT * FROM books b WHERE b.title == 'War and Peace'").AsEnumerable().FirstOrDefault();

Remarks

Refer to https://docs.microsoft.com/azure/cosmos-db/sql-query-getting-started/ for syntax and examples.

See also

Applies to

CreateDocumentQuery(String, SqlQuerySpec, FeedOptions)

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement with parameterized values. It returns an IQueryable{dynamic}. For more information on preparing SQL statements with parameterized values, please see SqlQuerySpec.

public System.Linq.IQueryable<dynamic> CreateDocumentQuery (string collectionLink, Microsoft.Azure.Documents.SqlQuerySpec querySpec, Microsoft.Azure.Documents.Client.FeedOptions feedOptions = default);
abstract member CreateDocumentQuery : string * Microsoft.Azure.Documents.SqlQuerySpec * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<obj>
override this.CreateDocumentQuery : string * Microsoft.Azure.Documents.SqlQuerySpec * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<obj>
Public Function CreateDocumentQuery (collectionLink As String, querySpec As SqlQuerySpec, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of Object)

Parameters

collectionLink
String

The link to the parent document collection.

querySpec
SqlQuerySpec

The SqlQuerySpec instance containing the SQL expression.

feedOptions
FeedOptions

The options for processing the query result feed. For details, see FeedOptions

Returns

an IQueryable{dynamic> that can evaluate the query.

Implements

Examples

This example below queries for book documents.

// SQL querying allows dynamic property access
var query = new SqlQuerySpec(
    "SELECT * FROM books b WHERE b.title = @title", 
    new SqlParameterCollection(new SqlParameter[] { new SqlParameter { Name = "@title", Value = "War and Peace" }}));

dynamic document = client.CreateDocumentQuery<dynamic>(collectionLink, query).AsEnumerable().FirstOrDefault();

Remarks

Refer to https://docs.microsoft.com/azure/cosmos-db/sql-query-getting-started/ for syntax and examples.

See also

Applies to

CreateDocumentQuery(String, FeedOptions, Object)

Caution

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB service. It returns IOrderedQueryable{Document}.

[System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")]
public System.Linq.IOrderedQueryable<Microsoft.Azure.Documents.Document> CreateDocumentQuery (string collectionLink, Microsoft.Azure.Documents.Client.FeedOptions feedOptions, object partitionKey);
[<System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")>]
member this.CreateDocumentQuery : string * Microsoft.Azure.Documents.Client.FeedOptions * obj -> System.Linq.IOrderedQueryable<Microsoft.Azure.Documents.Document>
Public Function CreateDocumentQuery (collectionLink As String, feedOptions As FeedOptions, partitionKey As Object) As IOrderedQueryable(Of Document)

Parameters

collectionLink
String

The link to the parent document collection. Alternatively, this can be a path link to the database when using an IPartitionResolver.

feedOptions
FeedOptions

The options for processing the query result feed. For details, see FeedOptions

partitionKey
Object

Optional partition key that can be used with an IPartitionResolver.

Returns

An IOrderedQueryable{Document} that can evaluate the query.

Attributes

Remarks

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use Partitioned Collections for higher storage and throughput.

Applies to

CreateDocumentQuery(Uri, FeedOptions)

Extension method to create a query for documents in the Azure Cosmos DB service.

public System.Linq.IOrderedQueryable<Microsoft.Azure.Documents.Document> CreateDocumentQuery (Uri documentCollectionOrDatabaseUri, Microsoft.Azure.Documents.Client.FeedOptions feedOptions = default);
abstract member CreateDocumentQuery : Uri * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IOrderedQueryable<Microsoft.Azure.Documents.Document>
override this.CreateDocumentQuery : Uri * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IOrderedQueryable<Microsoft.Azure.Documents.Document>
Public Function CreateDocumentQuery (documentCollectionOrDatabaseUri As Uri, Optional feedOptions As FeedOptions = Nothing) As IOrderedQueryable(Of Document)

Parameters

documentCollectionOrDatabaseUri
Uri

The URI of the document collection.

feedOptions
FeedOptions

The options for processing the query results feed.

Returns

The query result set.

Implements

Applies to

CreateDocumentQuery(String, FeedOptions)

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB service. It returns IOrderedQueryable{Document}.

public System.Linq.IOrderedQueryable<Microsoft.Azure.Documents.Document> CreateDocumentQuery (string collectionLink, Microsoft.Azure.Documents.Client.FeedOptions feedOptions = default);
abstract member CreateDocumentQuery : string * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IOrderedQueryable<Microsoft.Azure.Documents.Document>
override this.CreateDocumentQuery : string * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IOrderedQueryable<Microsoft.Azure.Documents.Document>
Public Function CreateDocumentQuery (collectionLink As String, Optional feedOptions As FeedOptions = Nothing) As IOrderedQueryable(Of Document)

Parameters

collectionLink
String

The link to the parent document collection.

feedOptions
FeedOptions

The options for processing the query result feed. For details, see FeedOptions

Returns

An IOrderedQueryable{Document} that can evaluate the query.

Implements

Examples

This example below queries for documents by id.

Document document = client.CreateDocumentQuery<Document>(collectionLink)
    .Where(d => d.Id == "War and Peace").AsEnumerable().FirstOrDefault();

Remarks

This overload should be used when the schema of the queried documents is unknown or when querying by ID and replacing/deleting documents. Since Document is a DynamicObject, it can be dynamically cast back to the original C# object.

See also

Applies to

CreateDocumentQuery(Uri, FeedOptions, Object)

Caution

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.

Extension method to create a query for documents in the Azure Cosmos DB service.

[System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")]
public System.Linq.IOrderedQueryable<Microsoft.Azure.Documents.Document> CreateDocumentQuery (Uri documentCollectionOrDatabaseUri, Microsoft.Azure.Documents.Client.FeedOptions feedOptions, object partitionKey);
[<System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")>]
member this.CreateDocumentQuery : Uri * Microsoft.Azure.Documents.Client.FeedOptions * obj -> System.Linq.IOrderedQueryable<Microsoft.Azure.Documents.Document>
Public Function CreateDocumentQuery (documentCollectionOrDatabaseUri As Uri, feedOptions As FeedOptions, partitionKey As Object) As IOrderedQueryable(Of Document)

Parameters

documentCollectionOrDatabaseUri
Uri

The URI of the document collection, e.g. dbs/db_rid/colls/coll_rid/. Alternatively, this can be a URI of the database when using an IPartitionResolver, e.g. dbs/db_rid/

feedOptions
FeedOptions

The options for processing the query results feed.

partitionKey
Object

The partition key that can be used with an IPartitionResolver.

Returns

The query result set.

Attributes

Remarks

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use Partitioned Collections for higher storage and throughput.

Applies to

CreateDocumentQuery<T>(Uri, SqlQuerySpec, FeedOptions)

Extension method to create a query for documents in the Azure Cosmos DB service.

public System.Linq.IQueryable<T> CreateDocumentQuery<T> (Uri documentCollectionOrDatabaseUri, Microsoft.Azure.Documents.SqlQuerySpec querySpec, Microsoft.Azure.Documents.Client.FeedOptions feedOptions = default);
abstract member CreateDocumentQuery : Uri * Microsoft.Azure.Documents.SqlQuerySpec * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<'T>
override this.CreateDocumentQuery : Uri * Microsoft.Azure.Documents.SqlQuerySpec * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<'T>
Public Function CreateDocumentQuery(Of T) (documentCollectionOrDatabaseUri As Uri, querySpec As SqlQuerySpec, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of T)

Type Parameters

T

The type of object to query.

Parameters

documentCollectionOrDatabaseUri
Uri

The URI of the document collection.

querySpec
SqlQuerySpec

The sql query.

feedOptions
FeedOptions

The options for processing the query results feed.

Returns

The query result set.

Implements

Applies to

CreateDocumentQuery<T>(Uri, String, FeedOptions, Object)

Caution

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.

Extension method to create a query for documents in the Azure Cosmos DB service.

[System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")]
public System.Linq.IQueryable<T> CreateDocumentQuery<T> (Uri documentCollectionOrDatabaseUri, string sqlExpression, Microsoft.Azure.Documents.Client.FeedOptions feedOptions, object partitionKey);
[<System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")>]
member this.CreateDocumentQuery : Uri * string * Microsoft.Azure.Documents.Client.FeedOptions * obj -> System.Linq.IQueryable<'T>
Public Function CreateDocumentQuery(Of T) (documentCollectionOrDatabaseUri As Uri, sqlExpression As String, feedOptions As FeedOptions, partitionKey As Object) As IQueryable(Of T)

Type Parameters

T

The type of object to query.

Parameters

documentCollectionOrDatabaseUri
Uri

The URI of the document collection, e.g. dbs/db_rid/colls/coll_rid/. Alternatively, this can be a URI of the database when using an IPartitionResolver, e.g. dbs/db_rid/

sqlExpression
String

The sql query.

feedOptions
FeedOptions

The options for processing the query results feed.

partitionKey
Object

The partition key that can be used with an IPartitionResolver.

Returns

The query result set.

Attributes

Remarks

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use Partitioned Collections for higher storage and throughput.

Applies to

CreateDocumentQuery<T>(Uri, SqlQuerySpec, FeedOptions, Object)

Caution

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.

Extension method to create a query for documents for the Azure Cosmos DB service.

[System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")]
public System.Linq.IQueryable<T> CreateDocumentQuery<T> (Uri documentCollectionOrDatabaseUri, Microsoft.Azure.Documents.SqlQuerySpec querySpec, Microsoft.Azure.Documents.Client.FeedOptions feedOptions, object partitionKey);
[<System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")>]
member this.CreateDocumentQuery : Uri * Microsoft.Azure.Documents.SqlQuerySpec * Microsoft.Azure.Documents.Client.FeedOptions * obj -> System.Linq.IQueryable<'T>
Public Function CreateDocumentQuery(Of T) (documentCollectionOrDatabaseUri As Uri, querySpec As SqlQuerySpec, feedOptions As FeedOptions, partitionKey As Object) As IQueryable(Of T)

Type Parameters

T

The type of object to query.

Parameters

documentCollectionOrDatabaseUri
Uri

The URI of the document collection, e.g. dbs/db_rid/colls/coll_rid/. Alternatively, this can be a URI of the database when using an IPartitionResolver, e.g. dbs/db_rid/

querySpec
SqlQuerySpec

The sql query.

feedOptions
FeedOptions

The options for processing the query results feed.

partitionKey
Object

The partition key that can be used with an IPartitionResolver.

Returns

The query result set.

Attributes

Remarks

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use Partitioned Collections for higher storage and throughput.

Applies to

CreateDocumentQuery<T>(String, String, FeedOptions, Object)

Caution

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement. It returns an IQueryable{T}.

[System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")]
public System.Linq.IQueryable<T> CreateDocumentQuery<T> (string collectionLink, string sqlExpression, Microsoft.Azure.Documents.Client.FeedOptions feedOptions, object partitionKey);
[<System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")>]
member this.CreateDocumentQuery : string * string * Microsoft.Azure.Documents.Client.FeedOptions * obj -> System.Linq.IQueryable<'T>
Public Function CreateDocumentQuery(Of T) (collectionLink As String, sqlExpression As String, feedOptions As FeedOptions, partitionKey As Object) As IQueryable(Of T)

Type Parameters

T

The type of object to query.

Parameters

collectionLink
String

The path link for the documents under a collection, e.g. dbs/db_rid/colls/coll_rid/docs/. Alternatively, this can be a path link to the database when using an IPartitionResolver, e.g. dbs/db_rid/

sqlExpression
String

The SQL statement.

feedOptions
FeedOptions

The options for processing the query result feed. For details, see FeedOptions

partitionKey
Object

The partition key that can be used with an IPartitionResolver.

Returns

An IQueryable{T} that can evaluate the query.

Attributes

Remarks

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use Partitioned Collections for higher storage and throughput.

Applies to

CreateDocumentQuery<T>(String, SqlQuerySpec, FeedOptions, Object)

Caution

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement with parameterized values. It returns an IQueryable{T}. For more information on preparing SQL statements with parameterized values, please see SqlQuerySpec.

[System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")]
public System.Linq.IQueryable<T> CreateDocumentQuery<T> (string collectionLink, Microsoft.Azure.Documents.SqlQuerySpec querySpec, Microsoft.Azure.Documents.Client.FeedOptions feedOptions, object partitionKey);
[<System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")>]
member this.CreateDocumentQuery : string * Microsoft.Azure.Documents.SqlQuerySpec * Microsoft.Azure.Documents.Client.FeedOptions * obj -> System.Linq.IQueryable<'T>
Public Function CreateDocumentQuery(Of T) (collectionLink As String, querySpec As SqlQuerySpec, feedOptions As FeedOptions, partitionKey As Object) As IQueryable(Of T)

Type Parameters

T

The type of object to query.

Parameters

collectionLink
String

The link to the parent document collection. Alternatively, this can be a path link to the database when using an IPartitionResolver.

querySpec
SqlQuerySpec

The SqlQuerySpec instance containing the SQL expression.

feedOptions
FeedOptions

The options for processing the query result feed. For details, see FeedOptions

partitionKey
Object

The partition key that can be used with an IPartitionResolver.

Returns

An IQueryable{T} that can evaluate the query.

Attributes

Remarks

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use Partitioned Collections for higher storage and throughput.

Applies to

CreateDocumentQuery<T>(Uri, String, FeedOptions)

Extension method to create a query for documents in the Azure Cosmos DB service.

public System.Linq.IQueryable<T> CreateDocumentQuery<T> (Uri documentCollectionOrDatabaseUri, string sqlExpression, Microsoft.Azure.Documents.Client.FeedOptions feedOptions = default);
abstract member CreateDocumentQuery : Uri * string * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<'T>
override this.CreateDocumentQuery : Uri * string * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<'T>
Public Function CreateDocumentQuery(Of T) (documentCollectionOrDatabaseUri As Uri, sqlExpression As String, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of T)

Type Parameters

T

the type of object to query.

Parameters

documentCollectionOrDatabaseUri
Uri

The URI of the document collection.

sqlExpression
String

The sql query.

feedOptions
FeedOptions

The options for processing the query results feed.

Returns

The query result set.

Implements

Applies to

CreateDocumentQuery<T>(Uri, FeedOptions, Object)

Caution

Support for IPartitionResolver based method overloads is now obsolete. Please use the override that does not take a partitionKey parameter.

Extension method to create a query for documents in the Azure Cosmos DB service.

[System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. Please use the override that does not take a partitionKey parameter.")]
public System.Linq.IOrderedQueryable<T> CreateDocumentQuery<T> (Uri documentCollectionOrDatabaseUri, Microsoft.Azure.Documents.Client.FeedOptions feedOptions, object partitionKey);
[<System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. Please use the override that does not take a partitionKey parameter.")>]
member this.CreateDocumentQuery : Uri * Microsoft.Azure.Documents.Client.FeedOptions * obj -> System.Linq.IOrderedQueryable<'T>
Public Function CreateDocumentQuery(Of T) (documentCollectionOrDatabaseUri As Uri, feedOptions As FeedOptions, partitionKey As Object) As IOrderedQueryable(Of T)

Type Parameters

T

the type of object to query.

Parameters

documentCollectionOrDatabaseUri
Uri

The URI of the document collection, e.g. dbs/db_rid/colls/coll_rid/. Alternatively, this can be a URI of the database when using an IPartitionResolver, e.g. dbs/db_rid/

feedOptions
FeedOptions

The options for processing the query results feed.

partitionKey
Object

The partition key that can be used with an IPartitionResolver.

Returns

The query result set.

Attributes

Remarks

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use Partitioned Collections for higher storage and throughput.

Applies to

CreateDocumentQuery<T>(String, String, FeedOptions)

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement. It returns an IQueryable{T}.

public System.Linq.IQueryable<T> CreateDocumentQuery<T> (string collectionLink, string sqlExpression, Microsoft.Azure.Documents.Client.FeedOptions feedOptions = default);
abstract member CreateDocumentQuery : string * string * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<'T>
override this.CreateDocumentQuery : string * string * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<'T>
Public Function CreateDocumentQuery(Of T) (collectionLink As String, sqlExpression As String, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of T)

Type Parameters

T

The type of object to query.

Parameters

collectionLink
String

The link to the parent collection.

sqlExpression
String

The SQL statement.

feedOptions
FeedOptions

The options for processing the query result feed. For details, see FeedOptions

Returns

An IQueryable{T} that can evaluate the query.

Implements

Examples

This example below queries for some book documents.

public class Book 
{
    [JsonProperty("title")]
    public string Title {get; set;}

    public Author Author {get; set;}

    public int Price {get; set;}
}

public class Author
{
    public string FirstName {get; set;}
    public string LastName {get; set;}
}

// Query by the Title property
Book book = client.CreateDocumentQuery<Book>(collectionLink, 
    "SELECT * FROM books b WHERE b.title  = 'War and Peace'").AsEnumerable().FirstOrDefault();

// Query a nested property
Book otherBook = client.CreateDocumentQuery<Book>(collectionLink,
    "SELECT * FROM books b WHERE b.Author.FirstName = 'Leo'").AsEnumerable().FirstOrDefault();

// Perform a range query (needs an IndexType.Range on price or FeedOptions.EnableScansInQuery)
foreach (Book matchingBook in client.CreateDocumentQuery<Book>(
    collectionLink, "SELECT * FROM books b where b.Price > 1000"))
{
    // Iterate through books
}

// Query asychronously. Optionally set FeedOptions.MaxItemCount to control page size
using (var queryable = client.CreateDocumentQuery<Book>(collectionLink, 
    "SELECT * FROM books b WHERE b.title  = 'War and Peace'", 
    new FeedOptions { MaxItemCount = 10 }).AsDocumentQuery())
{
    while (queryable.HasMoreResults) 
    {
        foreach(Book b in await queryable.ExecuteNextAsync<Book>())
        {
            // Iterate through books
        }
    }
}

Remarks

Refer to https://docs.microsoft.com/azure/cosmos-db/sql-query-getting-started/ for syntax and examples.

See also

Applies to

CreateDocumentQuery<T>(String, SqlQuerySpec, FeedOptions)

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB database using a SQL statement with parameterized values. It returns an IQueryable{T}. For more information on preparing SQL statements with parameterized values, please see SqlQuerySpec.

public System.Linq.IQueryable<T> CreateDocumentQuery<T> (string collectionLink, Microsoft.Azure.Documents.SqlQuerySpec querySpec, Microsoft.Azure.Documents.Client.FeedOptions feedOptions = default);
abstract member CreateDocumentQuery : string * Microsoft.Azure.Documents.SqlQuerySpec * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<'T>
override this.CreateDocumentQuery : string * Microsoft.Azure.Documents.SqlQuerySpec * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<'T>
Public Function CreateDocumentQuery(Of T) (collectionLink As String, querySpec As SqlQuerySpec, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of T)

Type Parameters

T

The type of object to query.

Parameters

collectionLink
String

The link to the parent document collection.

querySpec
SqlQuerySpec

The SqlQuerySpec instance containing the SQL expression.

feedOptions
FeedOptions

The options for processing the query result feed. For details, see FeedOptions

Returns

An IQueryable{T} that can evaluate the query.

Implements

Examples

This example below queries for some book documents.

public class Book 
{
    [JsonProperty("title")]
    public string Title {get; set;}

    public Author Author {get; set;}

    public int Price {get; set;}
}

public class Author
{
    public string FirstName {get; set;}
    public string LastName {get; set;}
}

// Query using Title
Book book, otherBook;

var query = new SqlQuerySpec(
    "SELECT * FROM books b WHERE b.title = @title", 
    new SqlParameterCollection(new SqlParameter[] { new SqlParameter { Name = "@title", Value = "War and Peace" }}));
book = client.CreateDocumentQuery<Book>(collectionLink, query).AsEnumerable().FirstOrDefault();

// Query a nested property
query = new SqlQuerySpec(
    "SELECT * FROM books b WHERE b.Author.FirstName = @firstName", 
    new SqlParameterCollection(new SqlParameter[] { new SqlParameter { Name = "@firstName", Value = "Leo" }}));
otherBook = client.CreateDocumentQuery<Book>(collectionLink, query).AsEnumerable().FirstOrDefault();

// Perform a range query (needs an IndexType.Range on price or FeedOptions.EnableScansInQuery)
query = new SqlQuerySpec(
    "SELECT * FROM books b WHERE b.Price > @minPrice", 
    new SqlParameterCollection(new SqlParameter[] { new SqlParameter { Name = "@minPrice", Value = 1000 }}));
foreach (Book b in client.CreateDocumentQuery<Book>(
    collectionLink, query))
{
    // Iterate through books
}

// Query asychronously. Optionally set FeedOptions.MaxItemCount to control page size
query = new SqlQuerySpec(
    "SELECT * FROM books b WHERE b.title = @title", 
    new SqlParameterCollection(new SqlParameter[] { new SqlParameter { Name = "@title", Value = "War and Peace" }}));

using (var queryable = client.CreateDocumentQuery<Book>(collectionLink, query, 
    new FeedOptions { MaxItemCount = 10 }).AsDocumentQuery())
{
    while (queryable.HasMoreResults) 
    {
        foreach(Book b in await queryable.ExecuteNextAsync<Book>())
        {
            // Iterate through books
        }
    }
}

Remarks

Refer to https://docs.microsoft.com/azure/cosmos-db/sql-query-getting-started/ for syntax and examples.

See also

Applies to

CreateDocumentQuery<T>(String, FeedOptions, Object)

Caution

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB service.

[System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")]
public System.Linq.IOrderedQueryable<T> CreateDocumentQuery<T> (string documentsFeedOrDatabaseLink, Microsoft.Azure.Documents.Client.FeedOptions feedOptions, object partitionKey);
[<System.Obsolete("Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput. Please use the override that does not take a partitionKey parameter.")>]
member this.CreateDocumentQuery : string * Microsoft.Azure.Documents.Client.FeedOptions * obj -> System.Linq.IOrderedQueryable<'T>
Public Function CreateDocumentQuery(Of T) (documentsFeedOrDatabaseLink As String, feedOptions As FeedOptions, partitionKey As Object) As IOrderedQueryable(Of T)

Type Parameters

T

The type of object to query.

Parameters

documentsFeedOrDatabaseLink
String

The path link for the documents under a collection, e.g. dbs/db_rid/colls/coll_rid/docs/. Alternatively, this can be a path link to the database when using an IPartitionResolver, e.g. dbs/db_rid/

feedOptions
FeedOptions

The options for processing the query result feed. For details, see FeedOptions

partitionKey
Object

The partition key that can be used with an IPartitionResolver.

Returns

An IOrderedQueryable{T} that can evaluate the query.

Attributes

Remarks

Support for IPartitionResolver based method overloads is now obsolete. It's recommended that you use Partitioned Collections for higher storage and throughput.

Applies to

CreateDocumentQuery<T>(Uri, FeedOptions)

Extension method to create a query for documents in the Azure Cosmos DB service.

public System.Linq.IOrderedQueryable<T> CreateDocumentQuery<T> (Uri documentCollectionUri, Microsoft.Azure.Documents.Client.FeedOptions feedOptions = default);
abstract member CreateDocumentQuery : Uri * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IOrderedQueryable<'T>
override this.CreateDocumentQuery : Uri * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IOrderedQueryable<'T>
Public Function CreateDocumentQuery(Of T) (documentCollectionUri As Uri, Optional feedOptions As FeedOptions = Nothing) As IOrderedQueryable(Of T)

Type Parameters

T

the type of object to query.

Parameters

documentCollectionUri
Uri

The URI of the document collection.

feedOptions
FeedOptions

The options for processing the query results feed.

Returns

The query result set.

Implements

Applies to

CreateDocumentQuery<T>(String, FeedOptions)

Overloaded. This method creates a query for documents under a collection in an Azure Cosmos DB service.

public System.Linq.IOrderedQueryable<T> CreateDocumentQuery<T> (string collectionLink, Microsoft.Azure.Documents.Client.FeedOptions feedOptions = default);
abstract member CreateDocumentQuery : string * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IOrderedQueryable<'T>
override this.CreateDocumentQuery : string * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IOrderedQueryable<'T>
Public Function CreateDocumentQuery(Of T) (collectionLink As String, Optional feedOptions As FeedOptions = Nothing) As IOrderedQueryable(Of T)

Type Parameters

T

The type of object to query.

Parameters

collectionLink
String

The link to the parent collection resource.

feedOptions
FeedOptions

The options for processing the query result feed. For details, see FeedOptions

Returns

An IOrderedQueryable{T} that can evaluate the query.

Implements

Examples

This example below queries for some book documents.

public class Book 
{
    [JsonProperty("title")]
    public string Title {get; set;}

    public Author Author {get; set;}

    public int Price {get; set;}
}

public class Author
{
    public string FirstName {get; set;}
    public string LastName {get; set;}
}

// Query by the Title property
Book book = client.CreateDocumentQuery<Book>(collectionLink).Where(b => b.Title == "War and Peace").AsEnumerable().FirstOrDefault();

// Query a nested property
Book otherBook = client.CreateDocumentQuery<Book>(collectionLink).Where(b => b.Author.FirstName == "Leo").AsEnumerable().FirstOrDefault();

// Perform a range query (needs an IndexType.Range on price or FeedOptions.EnableScansInQuery)
foreach (Book matchingBook in client.CreateDocumentQuery<Book>(collectionLink).Where(b => b.Price > 100))
{
    // Iterate through books
}

// Query asychronously. Optionally set FeedOptions.MaxItemCount to control page size
using (var queryable = client.CreateDocumentQuery<Book>(
    collectionLink,
    new FeedOptions { MaxItemCount = 10 })
    .Where(b => b.Title == "War and Peace")
    .AsDocumentQuery())
{
    while (queryable.HasMoreResults) 
    {
        foreach(Book b in await queryable.ExecuteNextAsync<Book>())
        {
            // Iterate through books
        }
    }
}

Remarks

The Azure Cosmos DB LINQ provider compiles LINQ to SQL statements. Refer to https://docs.microsoft.com/azure/cosmos-db/sql-query-linq-to-sql for the list of expressions supported by the Azure Cosmos DB LINQ provider. ToString() on the generated IQueryable returns the translated SQL statement. The Azure Cosmos DB provider translates JSON.NET and DataContract serialization attributes for members to their JSON property names.

See also

Applies to