DocumentQueryable.CreateAttachmentQuery Method
Namespace: Microsoft.Azure.Documents.Linq
Assembly: Microsoft.Azure.Documents.Client (in Microsoft.Azure.Documents.Client.dll)
Overload List
| Name | Description | |
|---|---|---|
![]() ![]() |
CreateAttachmentQuery(DocumentClient, String, FeedOptions) | Overloaded. This method creates create a query for attachments. It returns an IOrderedQueryable{Attachment}. |
![]() ![]() |
CreateAttachmentQuery(DocumentClient, String, SqlQuerySpec, FeedOptions) | Overloaded. This method creates a query for attachments 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(DocumentClient, String, String, FeedOptions) | Overloaded. This method creates a query for attachments by using a SQL statement. It returns an IQueryable{dynamic}. |
![]() ![]() |
CreateAttachmentQuery<T>(DocumentClient, String, FeedOptions) | Overloaded. This method creates a query for attachments. |
![]() ![]() |
CreateAttachmentQuery<T>(DocumentClient, String, SqlQuerySpec, FeedOptions) | Overloaded. This method creates a query for attachments by using a SQL statement with parameterized values. For more information on preparing SQL statements with parameterized values, please see SqlQuerySpec. |
![]() ![]() |
CreateAttachmentQuery<T>(DocumentClient, String, String, FeedOptions) | Overloaded. This method creates a query for attachments by using a SQL statement. |
See Also
DocumentQueryable Class
Microsoft.Azure.Documents.Linq Namespace
Return to top
DocumentQueryable.CreateAttachmentQuery Method (DocumentClient, String, FeedOptions)
Overloaded. This method creates create a query for attachments. It returns an IOrderedQueryable{Attachment}.
Syntax
public static IOrderedQueryable<Attachment> CreateAttachmentQuery(
this DocumentClient client,
string attachmentsLink,
FeedOptions feedOptions = null
)
public:
[ExtensionAttribute]
static IOrderedQueryable<Attachment^>^ CreateAttachmentQuery(
DocumentClient^ client,
String^ attachmentsLink,
FeedOptions^ feedOptions = null
)
<ExtensionAttribute>
Public Shared Function CreateAttachmentQuery (
client As DocumentClient,
attachmentsLink As String,
feedOptions As FeedOptions
) As IOrderedQueryable(Of Attachment)
Parameters
client
Type: Microsoft.Azure.Documents.Client.DocumentClientthe DocumentClient instance to execute the query.
attachmentsLink
Type: System.StringThe path link for the attachments under a document, e.g. dbs/db_rid/colls/coll_rid/docs/doc_rid/attachments/.
feedOptions
Type: Microsoft.Azure.Documents.Client.FeedOptionsThe options for processing the query result feed. For details, see FeedOptions
Return Value
Type: System.Linq.IOrderedQueryable<Attachment>
An IOrderedQueryable{Attachments} that can evaluate the query with the provided SQL statement.
Examples
This example below queries for plain text attachments using LINQ.
foreach (Attachment attachment in client.CreateAttachmentQuery(document.AttachmentsLink).Where(a => a.ContentType == "text/plain"))
{
Console.WriteLine("Id: {0}, MediaLink:{1}", attachment.Id, attachment.MediaLink);
}
See Also
Return to top
DocumentQueryable.CreateAttachmentQuery Method (DocumentClient, String, SqlQuerySpec, FeedOptions)
Overloaded. This method creates a query for attachments 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.
Syntax
public static IQueryable<object> CreateAttachmentQuery(
this DocumentClient client,
string attachmentsLink,
SqlQuerySpec querySpec,
FeedOptions feedOptions = null
)
public:
[ExtensionAttribute]
static IQueryable<Object^>^ CreateAttachmentQuery(
DocumentClient^ client,
String^ attachmentsLink,
SqlQuerySpec^ querySpec,
FeedOptions^ feedOptions = null
)
<ExtensionAttribute>
Public Shared Function CreateAttachmentQuery (
client As DocumentClient,
attachmentsLink As String,
querySpec As SqlQuerySpec,
feedOptions As FeedOptions
) As IQueryable(Of Object)
Parameters
client
Type: Microsoft.Azure.Documents.Client.DocumentClientthe DocumentClient instance to execute the query.
attachmentsLink
Type: System.StringThe path link for the attachments under a document, e.g. dbs/db_rid/colls/coll_rid/docs/doc_rid/attachments/.
querySpec
Type: Microsoft.Azure.Documents.SqlQuerySpecThe SqlQuerySpec instance containing the SQL expression.
feedOptions
Type: Microsoft.Azure.Documents.Client.FeedOptionsThe options for processing the query result feed. For details, see FeedOptions
Return Value
Type: System.Linq.IQueryable<Object>
An IQueryable{dynamic} that can evaluate the query with the provided SQL statement.
Remarks
Refer to https://msdn.microsoft.com/en-us/library/azure/dn782250.aspx and https://azure.microsoft.com/documentation/articles/documentdb-sql-query/ for syntax and examples.
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.AttachmentsLink, query))
{
Console.WriteLine("Id: {0}, Priority:{1}", attachment.id, attachment.priority);
}
See Also
Return to top
DocumentQueryable.CreateAttachmentQuery Method (DocumentClient, String, String, FeedOptions)
Overloaded. This method creates a query for attachments by using a SQL statement. It returns an IQueryable{dynamic}.
Syntax
public static IQueryable<object> CreateAttachmentQuery(
this DocumentClient client,
string attachmentsLink,
string sqlExpression,
FeedOptions feedOptions = null
)
public:
[ExtensionAttribute]
static IQueryable<Object^>^ CreateAttachmentQuery(
DocumentClient^ client,
String^ attachmentsLink,
String^ sqlExpression,
FeedOptions^ feedOptions = null
)
<ExtensionAttribute>
Public Shared Function CreateAttachmentQuery (
client As DocumentClient,
attachmentsLink As String,
sqlExpression As String,
feedOptions As FeedOptions
) As IQueryable(Of Object)
Parameters
client
Type: Microsoft.Azure.Documents.Client.DocumentClientthe DocumentClient instance to execute the query.
attachmentsLink
Type: System.StringThe path link for the attachments under a document, e.g. dbs/db_rid/colls/coll_rid/docs/doc_rid/attachments/.
sqlExpression
Type: System.StringThe SQL statement.
feedOptions
Type: Microsoft.Azure.Documents.Client.FeedOptionsThe options for processing the query result feed. For details, see FeedOptions
Return Value
Type: System.Linq.IQueryable<Object>
An IQueryable{dynamic} that can evaluate the query with the provided SQL statement.
Remarks
Refer to https://msdn.microsoft.com/en-us/library/azure/dn782250.aspx and https://azure.microsoft.com/documentation/articles/documentdb-sql-query/ for syntax and examples.
Examples
foreach (Attachment attachment in client.CreateAttachmentQuery<dynamic>(
document.AttachmentsLink,
"SELECT * FROM attachments a WHERE a.priority = 0"))
{
Console.WriteLine("Id: {0}, Priority:{1}", attachment.id, attachment.priority);
}
See Also
Return to top
DocumentQueryable.CreateAttachmentQuery<T> Method (DocumentClient, String, FeedOptions)
Overloaded. This method creates a query for attachments.
Syntax
public static IOrderedQueryable<T> CreateAttachmentQuery<T>(
this DocumentClient client,
string attachmentsLink,
FeedOptions feedOptions = null
)
public:
generic<typename T>
[ExtensionAttribute]
static IOrderedQueryable<T>^ CreateAttachmentQuery(
DocumentClient^ client,
String^ attachmentsLink,
FeedOptions^ feedOptions = null
)
<ExtensionAttribute>
Public Shared Function CreateAttachmentQuery(Of T) (
client As DocumentClient,
attachmentsLink As String,
feedOptions As FeedOptions
) As IOrderedQueryable(Of T)
Parameters
client
Type: Microsoft.Azure.Documents.Client.DocumentClientThe DocumentClient instance to execute the query.
attachmentsLink
Type: System.StringThe path link for the attachments under a document, e.g. dbs/db_rid/colls/coll_rid/docs/doc_rid/attachments/.
feedOptions
Type: Microsoft.Azure.Documents.Client.FeedOptionsThe options for processing the query result feed. For details, see FeedOptions
Return Value
Type: System.Linq.IOrderedQueryable<T>
An IOrderedQueryable{T} that can evaluate the query.
Type Parameters
- T
The type of object to query.
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.AttachmentsLink).Where(a => a.Priority == 0))
{
Console.WriteLine("Id: {0}, MediaLink:{1}", attachment.Id, attachment.MediaLink);
}
See Also
Return to top
DocumentQueryable.CreateAttachmentQuery<T> Method (DocumentClient, String, SqlQuerySpec, FeedOptions)
Overloaded. This method creates a query for attachments by using a SQL statement with parameterized values. For more information on preparing SQL statements with parameterized values, please see SqlQuerySpec.
Syntax
public static IQueryable<T> CreateAttachmentQuery<T>(
this DocumentClient client,
string attachmentsLink,
SqlQuerySpec querySpec,
FeedOptions feedOptions = null
)
public:
generic<typename T>
[ExtensionAttribute]
static IQueryable<T>^ CreateAttachmentQuery(
DocumentClient^ client,
String^ attachmentsLink,
SqlQuerySpec^ querySpec,
FeedOptions^ feedOptions = null
)
<ExtensionAttribute>
Public Shared Function CreateAttachmentQuery(Of T) (
client As DocumentClient,
attachmentsLink As String,
querySpec As SqlQuerySpec,
feedOptions As FeedOptions
) As IQueryable(Of T)
Parameters
client
Type: Microsoft.Azure.Documents.Client.DocumentClientthe DocumentClient instance to execute the query.
attachmentsLink
Type: System.StringThe path link for the attachments under a document, e.g. dbs/db_rid/colls/coll_rid/docs/doc_rid/attachments/.
querySpec
Type: Microsoft.Azure.Documents.SqlQuerySpecThe SqlQuerySpec instance containing the SQL expression.
feedOptions
Type: Microsoft.Azure.Documents.Client.FeedOptionsThe options for processing the query result feed. For details, see FeedOptions
Return Value
Type: System.Linq.IQueryable<T>
An IQueryable{T} that can evaluate the query with the provided SQL statement.
Type Parameters
- T
Remarks
Refer to https://msdn.microsoft.com/en-us/library/azure/dn782250.aspx and https://azure.microsoft.com/documentation/articles/documentdb-sql-query/ for syntax and examples.
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.AttachmentsLink, query))
{
Console.WriteLine("Id: {0}, MediaLink:{1}", attachment.Id, attachment.MediaLink);
}
See Also
Return to top
DocumentQueryable.CreateAttachmentQuery<T> Method (DocumentClient, String, String, FeedOptions)
Overloaded. This method creates a query for attachments by using a SQL statement.
Syntax
public static IQueryable<T> CreateAttachmentQuery<T>(
this DocumentClient client,
string attachmentsLink,
string sqlExpression,
FeedOptions feedOptions = null
)
public:
generic<typename T>
[ExtensionAttribute]
static IQueryable<T>^ CreateAttachmentQuery(
DocumentClient^ client,
String^ attachmentsLink,
String^ sqlExpression,
FeedOptions^ feedOptions = null
)
<ExtensionAttribute>
Public Shared Function CreateAttachmentQuery(Of T) (
client As DocumentClient,
attachmentsLink As String,
sqlExpression As String,
feedOptions As FeedOptions
) As IQueryable(Of T)
Parameters
client
Type: Microsoft.Azure.Documents.Client.DocumentClientthe DocumentClient instance to execute the query.
attachmentsLink
Type: System.StringThe path link for the attachments under a document, e.g. dbs/db_rid/colls/coll_rid/docs/doc_rid/attachments/.
sqlExpression
Type: System.StringThe SQL statement.
feedOptions
Type: Microsoft.Azure.Documents.Client.FeedOptionsThe options for processing the query result feed. For details, see FeedOptions
Return Value
Type: System.Linq.IQueryable<T>
An IQueryable{T} that can evaluate the query with the provided SQL statement.
Type Parameters
- T
Remarks
Refer to https://msdn.microsoft.com/en-us/library/azure/dn782250.aspx and https://azure.microsoft.com/documentation/articles/documentdb-sql-query/ for syntax and examples.
Examples
This example below queries for plain text attachments using a SQL query string.
foreach (Attachment attachment in client.CreateAttachmentQuery(
document.AttachmentsLink,
"SELECT * FROM attachments a WHERE a.contentType = 'text/plain'"))
{
Console.WriteLine("Id: {0}, MediaLink:{1}", attachment.Id, attachment.MediaLink);
}
See Also
Return to top
.jpeg)
.gif)