Share via


QueryAttribute Class

Definition

Defines a query string to be used in the API request.

public ref class QueryAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Parameter)]
[System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")]
public sealed class QueryAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Parameter)>]
[<System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")>]
type QueryAttribute = class
    inherit Attribute
Public NotInheritable Class QueryAttribute
Inherits Attribute
Inheritance
QueryAttribute
Attributes

Examples

[AutoClient("MyClient")]
interface IMyDependencyClient
{
    [Get("/api/users")]
    Task<string> GetUsersAsync([Query] string userName, [Query("id")] string userId, CancellationToken cancellationToken = default);
}

Remarks

Marks a method parameter as a query string for the request.

Constructors

QueryAttribute()

Initializes a new instance of the QueryAttribute class.

QueryAttribute(String)

Initializes a new instance of the QueryAttribute class.

Properties

Key

Gets the query key, if set.

Applies to