Share via


DocumentClient.CreateAttachmentQuery Method

Definition

Overloads

CreateAttachmentQuery(String, FeedOptions)

Overloaded. This method creates a query for attachments in the Azure Cosmos DB service. It returns an IOrderedQueryable{Attachment}.

CreateAttachmentQuery(Uri, FeedOptions)

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

CreateAttachmentQuery(String, SqlQuerySpec, FeedOptions)

Overloaded. This method creates a query for attachments in the Azure Cosmos DB service 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.

CreateAttachmentQuery(String, String, FeedOptions)

Overloaded. This method creates a query for attachments in the Azure Cosmos DB service by using a SQL statement. It returns an IQueryable{dynamic}.

CreateAttachmentQuery(Uri, SqlQuerySpec, FeedOptions)

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

CreateAttachmentQuery(Uri, String, FeedOptions)

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

CreateAttachmentQuery<T>(Uri, String, FeedOptions)

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

CreateAttachmentQuery<T>(Uri, SqlQuerySpec, FeedOptions)

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

CreateAttachmentQuery<T>(String, String, FeedOptions)

Overloaded. This method creates a query for attachments in the Azure Cosmos DB service by using a SQL statement.

CreateAttachmentQuery<T>(String, FeedOptions)

Overloaded. This method creates a query for attachments in the Azure Cosmos DB service.

CreateAttachmentQuery<T>(Uri, FeedOptions)

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

CreateAttachmentQuery<T>(String, SqlQuerySpec, FeedOptions)

Overloaded. This method creates a query for attachments in the Azure Cosmos DB service by using a SQL statement with parameterized values. For more information on preparing SQL statements with parameterized values, please see SqlQuerySpec.

CreateAttachmentQuery(String, FeedOptions)

Overloaded. This method creates a query for attachments in the Azure Cosmos DB service. It returns an IOrderedQueryable{Attachment}.

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

Parameters

documentLink
String

The link to the parent document

feedOptions
FeedOptions

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

Returns

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

Implements

Examples

This example below queries for plain text attachments using LINQ.

foreach (Attachment attachment in client.CreateAttachmentQuery(document.SelfLink).Where(a => a.ContentType == "text/plain"))
{
    Console.WriteLine("Id: {0}, MediaLink:{1}", attachment.Id, attachment.MediaLink);
}

See also

Applies to

CreateAttachmentQuery(Uri, FeedOptions)

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

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

Parameters

attachmentsUri
Uri

the URI to the attachments.

feedOptions
FeedOptions

The options for processing the query results feed.

Returns

The query result set.

Implements

Applies to

CreateAttachmentQuery(String, SqlQuerySpec, FeedOptions)

Overloaded. This method creates a query for attachments in the Azure Cosmos DB service 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> CreateAttachmentQuery (string documentLink, Microsoft.Azure.Documents.SqlQuerySpec querySpec, Microsoft.Azure.Documents.Client.FeedOptions feedOptions = default);
abstract member CreateAttachmentQuery : string * Microsoft.Azure.Documents.SqlQuerySpec * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<obj>
override this.CreateAttachmentQuery : string * Microsoft.Azure.Documents.SqlQuerySpec * Microsoft.Azure.Documents.Client.FeedOptions -> System.Linq.IQueryable<obj>
Public Function CreateAttachmentQuery (documentLink As String, querySpec As SqlQuerySpec, Optional feedOptions As FeedOptions = Nothing) As IQueryable(Of Object)

Parameters

documentLink
String

The link to the parent document resource.

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.

Implements

Examples

This example below queries for plain text attachments using a parameterized SQL query string.

var query = new SqlQuerySpec(
    "SELECT * FROM attachments a WHERE a.priority = @priority", 
    new SqlParameterCollection(new SqlParameter[] { new SqlParameter { Name = "@priority", Value = 0 } }));

foreach (dynamic attachment in client.CreateAttachmentQuery<dynamic>(document.SelfLink, query))
{
    Console.WriteLine("Id: {0}, Priority:{1}", attachment.id, attachment.priority);
}

Remarks

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

See also

Applies to

CreateAttachmentQuery(String, String, FeedOptions)

Overloaded. This method creates a query for attachments in the Azure Cosmos DB service by using a SQL statement. It returns an IQueryable{dynamic}.

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

Parameters

documentLink
String

The link to the parent document.

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.

Implements

Examples

foreach (Attachment attachment in client.CreateAttachmentQuery<dynamic>(
    document.SelfLink, 
    "SELECT * FROM attachments a WHERE a.priority = 0"))
{
    Console.WriteLine("Id: {0}, Priority:{1}", attachment.id, attachment.priority);
}

Remarks

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

See also

Applies to

CreateAttachmentQuery(Uri, SqlQuerySpec, FeedOptions)

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

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

Parameters

attachmentsUri
Uri

the URI to the attachments.

querySpec
SqlQuerySpec

The sql query.

feedOptions
FeedOptions

The options for processing the query results feed.

Returns

The query result set.

Implements

Applies to

CreateAttachmentQuery(Uri, String, FeedOptions)

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

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

Parameters

attachmentsUri
Uri

the URI to the attachments.

sqlExpression
String

The sql query.

feedOptions
FeedOptions

The options for processing the query results feed.

Returns

The query result set.

Implements

Applies to

CreateAttachmentQuery<T>(Uri, String, FeedOptions)

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

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

Type Parameters

T

Parameters

attachmentsUri
Uri

the URI to the attachments.

sqlExpression
String

The sql query.

feedOptions
FeedOptions

The options for processing the query results feed.

Returns

The query result set.

Implements

Applies to

CreateAttachmentQuery<T>(Uri, SqlQuerySpec, FeedOptions)

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

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

Type Parameters

T

Parameters

attachmentsUri
Uri

the URI to the attachments.

querySpec
SqlQuerySpec

The sql query.

feedOptions
FeedOptions

The options for processing the query results feed.

Returns

The query result set.

Implements

Applies to

CreateAttachmentQuery<T>(String, String, FeedOptions)

Overloaded. This method creates a query for attachments in the Azure Cosmos DB service by using a SQL statement.

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

Type Parameters

T

Parameters

documentLink
String

The link of the parent document.

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

Implements

Examples

This example below queries for plain text attachments using a SQL query string.

foreach (Attachment attachment in client.CreateAttachmentQuery(
    document.SelfLink, 
    "SELECT * FROM attachments a WHERE a.contentType = 'text/plain'"))
{
    Console.WriteLine("Id: {0}, MediaLink:{1}", attachment.Id, attachment.MediaLink);
}

Remarks

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

See also

Applies to

CreateAttachmentQuery<T>(String, FeedOptions)

Overloaded. This method creates a query for attachments in the Azure Cosmos DB service.

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

Type Parameters

T

The type of object to query.

Parameters

documentLink
String

The link of the parent document.

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 against attachments of custom types.

public class PriorityAttachment : Attachment
{
    [JsonProperty("priority")]
    public int Priority;
}

foreach (PriorityAttachment attachment in 
    client.CreateAttachmentQuery<PriorityAttachment>(document.SelfLink).Where(a => a.Priority == 0))
{
    Console.WriteLine("Id: {0}, MediaLink:{1}", attachment.Id, attachment.MediaLink);
}

See also

Applies to

CreateAttachmentQuery<T>(Uri, FeedOptions)

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

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

Type Parameters

T

the type of object to query.

Parameters

attachmentsUri
Uri

the URI to the attachments.

feedOptions
FeedOptions

The options for processing the query results feed.

Returns

The query result set.

Implements

Applies to

CreateAttachmentQuery<T>(String, SqlQuerySpec, FeedOptions)

Overloaded. This method creates a query for attachments in the Azure Cosmos DB service by using a SQL statement with parameterized values. For more information on preparing SQL statements with parameterized values, please see SqlQuerySpec.

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

Type Parameters

T

Parameters

documentLink
String

The link of the parent document.

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

Implements

Examples

This example below queries for plain text attachments using a parameterized SQL query string.

var query = new SqlQuerySpec(
    "SELECT * FROM attachments a WHERE a.contentType = @contentType", 
    new SqlParameterCollection(new SqlParameter[] { new SqlParameter { Name = "@contentType", Value = "text/plain" } }));

foreach (Attachment attachment in client.CreateAttachmentQuery(document.SelfLink, query))
{
    Console.WriteLine("Id: {0}, MediaLink:{1}", attachment.Id, attachment.MediaLink);
}

Remarks

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

See also

Applies to