public static MyQueryInfo GetQueryInfo(this MyContext context) { var info = new MyQueryInfo(); var theGroup = context.GetOrCreate(context.GetGroupName_QueryInfos()); theGroup.Items.SetProperties(info); return(info); }
public static MyContext SetQueryInfo(this MyContext context, HttpRequest httpRequest) { var theGroup = context.GetOrCreate(context.GetGroupName_QueryInfos()); var queryCollection = httpRequest.Query; var keys = queryCollection.Keys; foreach (var key in keys) { if (!queryCollection.TryGetValue(key, out var values)) { theGroup.Items[key] = null; } else { values = values.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); foreach (var value in values) { //set by last one theGroup.Items[key] = value; } } } return(context); }