You can write an extension method and use reflection to set your properties, like this:
public static void SetProperties<T>(this T source, HttpContext context)
{
var properties = typeof(T)
.GetProperties(BindingFlags.Instance | BindingFlags.Public);
var values = context.Request.QueryString;
foreach (var prop in properties)
{
if (values.AllKeys.Contains(prop.Name))
{
prop.SetValue(source,values[prop.Name]);
}
}
}
Usage:
mode.SetProperties(HttpContext.Current);
This assumes that your keys in the query string are exactly matches with your property names of the model
.