Share via


IDocumentClient.CreateDatabaseQuery Method

Definition

Overloads

CreateDatabaseQuery(FeedOptions)

Overloaded. This method creates a query for database resources under an account in the Azure Cosmos DB service. It returns An IOrderedQueryable{Database}.

CreateDatabaseQuery(SqlQuerySpec, FeedOptions)

Overloaded. This method creates a query for database resources under an Azure Cosmos DB database account by 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.

CreateDatabaseQuery(String, FeedOptions)

Overloaded. This method creates a query for database resources under an Azure Cosmos DB database account by using a SQL statement. It returns an IQueryable{dynamic}.

CreateDatabaseQuery(FeedOptions)

Overloaded. This method creates a query for database resources under an account in the Azure Cosmos DB service. It returns An IOrderedQueryable{Database}.

public System.Linq.IOrderedQueryable<Microsoft.Azure.Documents.Database> CreateDatabaseQuery (Microsoft.Azure.Documents.Client.FeedOptions feedOptions = default);
abstract member CreateDatabaseQuery : Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IOrderedQueryable<Microsoft.Azure.Documents.Database>
Public Function CreateDatabaseQuery (Optional feedOptions As FeedOptions = Nothing) As IOrderedQueryable(Of Database)

Parameters

feedOptions
FeedOptions

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

Returns

An IOrderedQueryable{Database} that can evaluate the query with the provided SQL statement.

Examples

This example below queries for databases by id.

Database database = client.CreateDatabaseQuery().Where(d => d.Id == "mydb").AsEnumerable().FirstOrDefault();

Remarks

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

ReadDatabaseAsync(Uri, RequestOptions) is recommended for single database look-up.

See also

Applies to

CreateDatabaseQuery(SqlQuerySpec, FeedOptions)

Overloaded. This method creates a query for database resources under an Azure Cosmos DB database account by 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> CreateDatabaseQuery (Microsoft.Azure.Documents.SqlQuerySpec querySpec, Microsoft.Azure.Documents.Client.FeedOptions feedOptions = default);
abstract member CreateDatabaseQuery : Microsoft.Azure.Documents.SqlQuerySpec * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<obj>
Public Function CreateDatabaseQuery (querySpec As SqlQuerySpec, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of Object)

Parameters

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 with the provided SQL statement.

Examples

This example below queries for databases by id.

var query = new SqlQuerySpec("SELECT * FROM dbs d WHERE d.id = @id",
    new SqlParameterCollection(new SqlParameter[] { new SqlParameter { Name = "@id", Value = "mydb" }}));
dynamic database = client.CreateDatabaseQuery<dynamic>(query).AsEnumerable().FirstOrDefault();

Remarks

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

ReadDatabaseAsync(Uri, RequestOptions) is recommended for single database look-up.

See also

Applies to

CreateDatabaseQuery(String, FeedOptions)

Overloaded. This method creates a query for database resources under an Azure Cosmos DB database account by using a SQL statement. It returns an IQueryable{dynamic}.

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

Parameters

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 with the provided SQL statement.

Examples

This example below queries for databases by id.

Database database = client.CreateDatabaseQuery("SELECT * FROM dbs d WHERE d.id = 'mydb'").AsEnumerable().FirstOrDefault();

Remarks

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

ReadDatabaseAsync(Uri, RequestOptions) is recommended for single database look-up.

See also

Applies to