次の方法で共有


IDocumentClient.CreateDocumentQuery メソッド

定義

オーバーロード

CreateDocumentQuery(String, FeedOptions)

オーバーロードされます。 このメソッドは、Azure Cosmos DB サービスのコレクションの下にドキュメントのクエリを作成します。 IOrderedQueryable{Document} を返します。

CreateDocumentQuery(Uri, FeedOptions)

Azure Cosmos DB サービスでドキュメントのクエリを作成するメソッド。

CreateDocumentQuery(String, SqlQuerySpec, FeedOptions)

オーバーロードされます。 このメソッドは、パラメーター化された値を持つ SQL ステートメントを使用して、Azure Cosmos DB データベース内のコレクションの下にドキュメントのクエリを作成します。 IQueryable{dynamic} を返します。 パラメーター化された値を使用した SQL ステートメントの準備の詳細については、 を参照してください SqlQuerySpec

CreateDocumentQuery(String, String, FeedOptions)

オーバーロードされます。 このメソッドは、SQL ステートメントを使用して、Azure Cosmos DB データベース内のコレクションの下にドキュメントのクエリを作成します。 IQueryable{dynamic} を返します。

CreateDocumentQuery(Uri, SqlQuerySpec, FeedOptions)

Azure Cosmos DB サービスでドキュメントのクエリを作成するメソッド。

CreateDocumentQuery(Uri, String, FeedOptions)

Azure Cosmos DB サービスでドキュメントのクエリを作成するメソッド。

CreateDocumentQuery<T>(Uri, SqlQuerySpec, FeedOptions)

Azure Cosmos DB サービスでドキュメントのクエリを作成するメソッド。

CreateDocumentQuery<T>(Uri, String, FeedOptions)

Azure Cosmos DB サービスでドキュメントのクエリを作成するメソッド。

CreateDocumentQuery<T>(String, String, FeedOptions)

オーバーロードされます。 このメソッドは、SQL ステートメントを使用して、Azure Cosmos DB データベース内のコレクションの下にドキュメントのクエリを作成します。 IQueryable{T} を返します。

CreateDocumentQuery<T>(String, SqlQuerySpec, FeedOptions)

オーバーロードされます。 このメソッドは、パラメーター化された値を持つ SQL ステートメントを使用して、Azure Cosmos DB データベース内のコレクションの下にドキュメントのクエリを作成します。 IQueryable{T} を返します。 パラメーター化された値を使用した SQL ステートメントの準備の詳細については、 を参照してください SqlQuerySpec

CreateDocumentQuery<T>(Uri, FeedOptions)

Azure Cosmos DB サービスでドキュメントのクエリを作成するメソッド。

CreateDocumentQuery<T>(String, FeedOptions)

オーバーロードされます。 このメソッドは、Azure Cosmos DB サービスのコレクションの下にドキュメントのクエリを作成します。

CreateDocumentQuery(String, FeedOptions)

オーバーロードされます。 このメソッドは、Azure Cosmos DB サービスのコレクションの下にドキュメントのクエリを作成します。 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>
Public Function CreateDocumentQuery (collectionLink As String, Optional feedOptions As FeedOptions = Nothing) As IOrderedQueryable(Of Document)

パラメーター

collectionLink
String

親ドキュメント コレクションへのリンク。

feedOptions
FeedOptions

クエリ結果フィードを処理するためのオプション。 詳細については、FeedOptions を参照してください

戻り値

クエリを評価できる IOrderedQueryable{Document}。

次の例では、ID でドキュメントを照会します。

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

注釈

このオーバーロードは、クエリ対象のドキュメントのスキーマが不明な場合、または ID でクエリを実行してドキュメントを置換または削除する場合に使用する必要があります。 Document は DynamicObject であるため、元の C# オブジェクトに動的にキャストバックできます。

こちらもご覧ください

適用対象

CreateDocumentQuery(Uri, FeedOptions)

Azure Cosmos DB サービスでドキュメントのクエリを作成するメソッド。

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

パラメーター

documentCollectionUri
Uri

ドキュメント コレクションの URI。

feedOptions
FeedOptions

(省略可能) FeedOptions クエリ結果フィードを処理するための 。

戻り値

クエリ結果セット。

適用対象

CreateDocumentQuery(String, SqlQuerySpec, FeedOptions)

オーバーロードされます。 このメソッドは、パラメーター化された値を持つ SQL ステートメントを使用して、Azure Cosmos DB データベース内のコレクションの下にドキュメントのクエリを作成します。 IQueryable{dynamic} を返します。 パラメーター化された値を使用した SQL ステートメントの準備の詳細については、 を参照してください 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>
Public Function CreateDocumentQuery (collectionLink As String, querySpec As SqlQuerySpec, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of Object)

パラメーター

collectionLink
String

親ドキュメント コレクションへのリンク。

querySpec
SqlQuerySpec

SQL 式を含む SqlQuerySpec インスタンス。

feedOptions
FeedOptions

クエリ結果フィードを処理するためのオプション。 詳細については、FeedOptions を参照してください

戻り値

クエリを評価できる IQueryable{dynamic> 。

次の例では、書籍ドキュメントのクエリを実行します。

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

注釈

構文と例については、 を https://docs.microsoft.com/azure/cosmos-db/sql-query-getting-started/ 参照してください。

こちらもご覧ください

適用対象

CreateDocumentQuery(String, String, FeedOptions)

オーバーロードされます。 このメソッドは、SQL ステートメントを使用して、Azure Cosmos DB データベース内のコレクションの下にドキュメントのクエリを作成します。 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>
Public Function CreateDocumentQuery (collectionLink As String, sqlExpression As String, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of Object)

パラメーター

collectionLink
String

親ドキュメント コレクションへのリンク。

sqlExpression
String

SQL ステートメント。

feedOptions
FeedOptions

クエリ結果フィードを処理するためのオプション。 詳細については、FeedOptions を参照してください

戻り値

クエリを評価できる IQueryable{dynamic> 。

次の例では、書籍ドキュメントのクエリを実行します。

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

注釈

構文と例については、 を https://docs.microsoft.com/azure/cosmos-db/sql-query-getting-started/ 参照してください。

こちらもご覧ください

適用対象

CreateDocumentQuery(Uri, SqlQuerySpec, FeedOptions)

Azure Cosmos DB サービスでドキュメントのクエリを作成するメソッド。

public System.Linq.IQueryable<dynamic> CreateDocumentQuery (Uri documentCollectionUri, 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>
Public Function CreateDocumentQuery (documentCollectionUri As Uri, querySpec As SqlQuerySpec, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of Object)

パラメーター

documentCollectionUri
Uri

ドキュメント コレクションの URI。

querySpec
SqlQuerySpec

sql クエリ。

feedOptions
FeedOptions

(省略可能) FeedOptions クエリ結果フィードを処理するための 。

戻り値

クエリ結果セット。

適用対象

CreateDocumentQuery(Uri, String, FeedOptions)

Azure Cosmos DB サービスでドキュメントのクエリを作成するメソッド。

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

パラメーター

documentCollectionUri
Uri

ドキュメント コレクションの URI。

sqlExpression
String

sql クエリ。

feedOptions
FeedOptions

(省略可能) FeedOptions クエリ結果フィードを処理するための 。

戻り値

クエリ結果セット。

適用対象

CreateDocumentQuery<T>(Uri, SqlQuerySpec, FeedOptions)

Azure Cosmos DB サービスでドキュメントのクエリを作成するメソッド。

public System.Linq.IQueryable<T> CreateDocumentQuery<T> (Uri documentCollectionUri, 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>
Public Function CreateDocumentQuery(Of T) (documentCollectionUri As Uri, querySpec As SqlQuerySpec, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of T)

型パラメーター

T

クエリを実行するオブジェクトの型。

パラメーター

documentCollectionUri
Uri

ドキュメント コレクションの URI。

querySpec
SqlQuerySpec

sql クエリ。

feedOptions
FeedOptions

(省略可能) FeedOptions クエリ結果フィードを処理するための 。

戻り値

クエリ結果セット。

適用対象

CreateDocumentQuery<T>(Uri, String, FeedOptions)

Azure Cosmos DB サービスでドキュメントのクエリを作成するメソッド。

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

型パラメーター

T

クエリを実行するオブジェクトの型。

パラメーター

documentCollectionUri
Uri

ドキュメント コレクションの URI。

sqlExpression
String

sql クエリ。

feedOptions
FeedOptions

(省略可能) FeedOptions クエリ結果フィードを処理するための 。

戻り値

クエリ結果セット。

適用対象

CreateDocumentQuery<T>(String, String, FeedOptions)

オーバーロードされます。 このメソッドは、SQL ステートメントを使用して、Azure Cosmos DB データベース内のコレクションの下にドキュメントのクエリを作成します。 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>
Public Function CreateDocumentQuery(Of T) (collectionLink As String, sqlExpression As String, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of T)

型パラメーター

T

クエリを実行するオブジェクトの型。

パラメーター

collectionLink
String

親コレクションへのリンク。

sqlExpression
String

SQL ステートメント。

feedOptions
FeedOptions

クエリ結果フィードを処理するためのオプション。 詳細については、FeedOptions を参照してください

戻り値

クエリを評価できる IQueryable{T}。

次の例では、一部の書籍ドキュメントのクエリを実行します。

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
        }
    }
}

注釈

構文と例については、 を https://docs.microsoft.com/azure/cosmos-db/sql-query-getting-started/ 参照してください。

こちらもご覧ください

適用対象

CreateDocumentQuery<T>(String, SqlQuerySpec, FeedOptions)

オーバーロードされます。 このメソッドは、パラメーター化された値を持つ SQL ステートメントを使用して、Azure Cosmos DB データベース内のコレクションの下にドキュメントのクエリを作成します。 IQueryable{T} を返します。 パラメーター化された値を使用した SQL ステートメントの準備の詳細については、 を参照してください 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>
Public Function CreateDocumentQuery(Of T) (collectionLink As String, querySpec As SqlQuerySpec, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of T)

型パラメーター

T

クエリを実行するオブジェクトの型。

パラメーター

collectionLink
String

親ドキュメント コレクションへのリンク。

querySpec
SqlQuerySpec

SQL 式を含む SqlQuerySpec インスタンス。

feedOptions
FeedOptions

クエリ結果フィードを処理するためのオプション。 詳細については、FeedOptions を参照してください

戻り値

クエリを評価できる IQueryable{T}。

次の例では、一部の書籍ドキュメントのクエリを実行します。

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
        }
    }
}

注釈

構文と例については、 を https://docs.microsoft.com/azure/cosmos-db/sql-query-getting-started/ 参照してください。

こちらもご覧ください

適用対象

CreateDocumentQuery<T>(Uri, FeedOptions)

Azure Cosmos DB サービスでドキュメントのクエリを作成するメソッド。

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>
Public Function CreateDocumentQuery(Of T) (documentCollectionUri As Uri, Optional feedOptions As FeedOptions = Nothing) As IOrderedQueryable(Of T)

型パラメーター

T

クエリを実行するオブジェクトの型。

パラメーター

documentCollectionUri
Uri

親ドキュメント コレクションの URI。

feedOptions
FeedOptions

(省略可能) FeedOptions クエリ結果フィードを処理するための 。

戻り値

クエリ結果セット。

適用対象

CreateDocumentQuery<T>(String, FeedOptions)

オーバーロードされます。 このメソッドは、Azure Cosmos DB サービスのコレクションの下にドキュメントのクエリを作成します。

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>
Public Function CreateDocumentQuery(Of T) (collectionLink As String, Optional feedOptions As FeedOptions = Nothing) As IOrderedQueryable(Of T)

型パラメーター

T

クエリを実行するオブジェクトの型。

パラメーター

collectionLink
String

親コレクション リソースへのリンク。

feedOptions
FeedOptions

クエリ結果フィードを処理するためのオプション。 詳細については、FeedOptions を参照してください

戻り値

クエリを評価できる IOrderedQueryable{T}。

次の例では、一部の書籍ドキュメントのクエリを実行します。

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
        }
    }
}

注釈

Azure Cosmos DB LINQ プロバイダーは、LINQ to SQL ステートメントをコンパイルします。 https://docs.microsoft.com/azure/cosmos-db/sql-query-linq-to-sql Azure Cosmos DB LINQ プロバイダーでサポートされている式の一覧については、こちらを参照してください。 生成された IQueryable の ToString() は、変換された SQL ステートメントを返します。 Azure Cosmos DB プロバイダーは、メンバーの JSON.NET および DataContract シリアル化属性を JSON プロパティ名に変換します。

こちらもご覧ください

適用対象