- 
                Notifications
    You must be signed in to change notification settings 
- Fork 10.5k
Description
Is your feature request related to a problem? Please describe.
I am trying to create complex queries from generic object, the opposite of what [fromQuery] attribute is doing related to class-types. QueryHelpers.AddQueryString would do, however I need to access private version with
IEnumerable<KeyValuePair<string, string>> queryString parameter, or a new version with Dictionary<string, StringValues> parameter.
To support array types like for queries like ids=1&ids=2&ids=3, because Dictionary version forces key uniqueness.
Describe the solution you'd like
public modification for the linked method or another way to create query from the object, including support the list of parameters like ids=1&ids=2&ids=3
Describe alternatives you've considered
Add each value with AddQueryString(string uri, string name, string value). I wonder how massive string concat will impact memory, also I think methods should support each other so I could easily use AddQueryString and ParseQuery together.
Additional context
Code context:
public static string AppendObjectToQueryString(string uri, object requestObject)
{
	var type = requestObject.GetType();
	var data = type.GetProperties(BindingFlags.Public | BindingFlags.Instance)
		.ToDictionary
		(
			p => p.Name,
			p => p.GetValue(requestObject)
		);
	foreach (var d in data)
	{
		if (d.Value == null)
		{
			continue;
		}
		if ((d.Value as string == null) && d.Value is IEnumerable enumerable)
		{
			foreach (var value in enumerable)
			{
				uri = QueryHelpers.AddQueryString(uri, d.Key, value.ToString());
			}
		}
		else
		{
			uri = QueryHelpers.AddQueryString(uri, d.Key, d.Value.ToString());
		}
	}
	return uri;
}