public static UriBuilder SetQueryParameters(this UriBuilder uri, object data) { uri.Query = string.Join("&", data.GetType() .GetProperties() .Select(x => new { Key = x.Name, Value = x.GetValue(data) }) .Where(x => x.Value != null) .Select(x => HttpUtility.UrlEncode(x.Key) + "=" + HttpUtility.UrlEncode(x.Value.ToString()))); return uri; }