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
queryIQueryCollectionThe query to retrieve a DateTime value from.
keystringThe key associated with the parameter to retrieve.
defaultValueDateTimeThe default value if the value does not exist.
Returns
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
queryIQueryCollectionThe query to retrieve an integer value from.
keystringThe key associated with the parameter to retrieve.
defaultValueintThe default value if the value does not exist.
treatZeroAsEmptyboolA 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
queryIQueryCollectionThe query to retrieve a string value from.
keystringThe key associated with the parameter to retrieve.
defaultValuestringThe default value if the value does not exist.
Returns
- string
The string value for the specified
key.