Database.GetUserQueryIterator Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
GetUserQueryIterator<T>(QueryDefinition, String, QueryRequestOptions) |
This method creates a query for users under an database using a SQL statement with parameterized values. It returns a FeedIterator. For more information on preparing SQL statements with parameterized values, please see QueryDefinition overload. |
GetUserQueryIterator<T>(String, String, QueryRequestOptions) |
This method creates a query for users under an database using a SQL statement. It returns a FeedIterator. |
GetUserQueryIterator<T>(QueryDefinition, String, QueryRequestOptions)
- Source:
- Database.cs
This method creates a query for users under an database using a SQL statement with parameterized values. It returns a FeedIterator. For more information on preparing SQL statements with parameterized values, please see QueryDefinition overload.
public abstract Microsoft.Azure.Cosmos.FeedIterator<T> GetUserQueryIterator<T> (Microsoft.Azure.Cosmos.QueryDefinition queryDefinition, string continuationToken = default, Microsoft.Azure.Cosmos.QueryRequestOptions requestOptions = default);
abstract member GetUserQueryIterator : Microsoft.Azure.Cosmos.QueryDefinition * string * Microsoft.Azure.Cosmos.QueryRequestOptions -> Microsoft.Azure.Cosmos.FeedIterator<'T>
Public MustOverride Function GetUserQueryIterator(Of T) (queryDefinition As QueryDefinition, Optional continuationToken As String = Nothing, Optional requestOptions As QueryRequestOptions = Nothing) As FeedIterator(Of T)
Type Parameters
- T
Parameters
- queryDefinition
- QueryDefinition
The Cosmos SQL query definition.
- continuationToken
- String
(Optional) The continuation token in the Azure Cosmos DB service.
- requestOptions
- QueryRequestOptions
(Optional) The options for the user query request.
Returns
An iterator to go through the users
Examples
This create the type feed iterator for users with queryDefinition as input.
QueryDefinition queryDefinition = new QueryDefinition("SELECT * FROM c where c.status like @status")
.WithParameter("@status", "start%");
using (FeedIterator<UserProperties> resultSet = this.cosmosDatabase.GetUserQueryIterator<UserProperties>(queryDefinition))
{
while (feedIterator.HasMoreResults)
{
foreach (UserProperties properties in await feedIterator.ReadNextAsync())
{
Console.WriteLine(properties.Id);
}
}
}
Applies to
GetUserQueryIterator<T>(String, String, QueryRequestOptions)
- Source:
- Database.cs
This method creates a query for users under an database using a SQL statement. It returns a FeedIterator.
public abstract Microsoft.Azure.Cosmos.FeedIterator<T> GetUserQueryIterator<T> (string queryText = default, string continuationToken = default, Microsoft.Azure.Cosmos.QueryRequestOptions requestOptions = default);
abstract member GetUserQueryIterator : string * string * Microsoft.Azure.Cosmos.QueryRequestOptions -> Microsoft.Azure.Cosmos.FeedIterator<'T>
Public MustOverride Function GetUserQueryIterator(Of T) (Optional queryText As String = Nothing, Optional continuationToken As String = Nothing, Optional requestOptions As QueryRequestOptions = Nothing) As FeedIterator(Of T)
Type Parameters
- T
Parameters
- queryText
- String
The Cosmos SQL query text.
- continuationToken
- String
(Optional) The continuation token in the Azure Cosmos DB service.
- requestOptions
- QueryRequestOptions
(Optional) The options for the user query request.
Returns
An iterator to go through the users
Examples
- This create the type feed iterator for users with queryText as input,
string queryText = "SELECT * FROM c where c.status like 'start%'";
using (FeedIterator<UserProperties> HasMoreResults = this.cosmosDatabase.GetUserQueryIterator<UserProperties>(queryText))
{
while (feedIterator.HasMoreResults)
{
FeedResponse<UserProperties> response = await feedIterator.ReadNextAsync();
foreach (var user in response)
{
Console.WriteLine(user);
}
}
}
- This create the type feed iterator for users without queryText, retrieving all users.
using (FeedIterator<UserProperties> feedIterator = this.cosmosDatabase.GetUserQueryIterator<UserProperties>())
{
while (feedIterator.HasMoreResults)
{
FeedResponse<UserProperties> response = await feedIterator.ReadNextAsync();
foreach (var user in response)
{
Console.WriteLine(user);
}
}
}
Applies to
Azure SDK for .NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기