อ่านในภาษาอังกฤษ

แชร์ผ่าน


QueryAttribute Class

Definition

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

C#
[System.AttributeUsage(System.AttributeTargets.Parameter)]
[System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")]
public sealed class QueryAttribute : 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

ผลิตภัณฑ์ เวอร์ชัน
.NET 6 (package-provided), 7 (package-provided), 8 (package-provided), 9 (package-provided), 10 (package-provided)