Table of Contents

Class QueryCollectionExtensions

Namespace
MADE.Web.Extensions
Assembly
MADE.Web.dll

Defines a collection of extensions for IQueryCollection objects.

public static class QueryCollectionExtensions
Inheritance
QueryCollectionExtensions
Inherited Members

Methods

GetDateTimeValueOrDefault(IQueryCollection, string, DateTime)

Gets a DateTime value from the query by the specified key.

public static DateTime GetDateTimeValueOrDefault(this IQueryCollection query, string key, DateTime defaultValue)

Parameters

query IQueryCollection

The query to retrieve a DateTime value from.

key string

The key associated with the parameter to retrieve.

defaultValue DateTime

The default value if the value does not exist.

Returns

DateTime

The DateTime value for the specified key.

GetIntValueOrDefault(IQueryCollection, string, int, bool)

Gets an integer value from the query by the specified key.

public static int GetIntValueOrDefault(this IQueryCollection query, string key, int defaultValue, bool treatZeroAsEmpty = true)

Parameters

query IQueryCollection

The query to retrieve an integer value from.

key string

The key associated with the parameter to retrieve.

defaultValue int

The default value if the value does not exist.

treatZeroAsEmpty bool

A value indicating whether to treat 0 as empty. True by default.

Returns

int

The integer value for the specified key.

GetStringValueOrDefault(IQueryCollection, string, string?)

Gets a string value from the query by the specified key.

public static string? GetStringValueOrDefault(this IQueryCollection query, string key, string? defaultValue = null)

Parameters

query IQueryCollection

The query to retrieve a string value from.

key string

The key associated with the parameter to retrieve.

defaultValue string

The default value if the value does not exist.

Returns

string

The string value for the specified key.