Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is the way I have gotten this to work so all my dropdowns have the correct values. It FEELS like I'm doing something wrong with it, but it works and I'm on a deadline so it will have to do for now. Maybe later I'll be able to get a better solution. Maybe someone on StackOverflow will provide a better solution - we'll see!</p> <pre><code>/// Do Stuff in Async method using (HttpClient hc = new HttpClient()) { hc.BaseAddress = CatalogUri; hc.DefaultRequestHeaders.Accept.Add(HttpJsonHeader); if (Session["StandardSearchOptions"] == null || rebindStandardOptions) { // request for standard options HttpResponseMessage stdResponse = hc.PostAsJsonAsync(CatalogSearchOptionPath, searchmeta).Result; IEnumerable&lt;Task&lt;KeyValuePair&lt;string, List&lt;string&gt;&gt;&gt;&gt; tasks = from key in keynames select GetCustomOptionList(key, hc, searchmeta); customOptions = new ConcurrentDictionary&lt;string, List&lt;string&gt;&gt;(await Task.WhenAll(tasks)); if (stdResponse.IsSuccessStatusCode) { string g = stdResponse.Content.ReadAsStringAsync().Result; stdOptions = Newtonsoft.Json .JsonConvert.DeserializeObject&lt;List&lt;SearchOption&gt;&gt;(g); } Session["StandardSearchOptions"] = stdOptions; } else // only rebinding the custom options { IEnumerable&lt;Task&lt;KeyValuePair&lt;string, List&lt;string&gt;&gt;&gt;&gt; tasks = from key in keynames select GetCustomOptionList(key, hc, searchmeta); customOptions = new ConcurrentDictionary&lt;string, List&lt;string&gt;&gt;(await Task.WhenAll(tasks)); } } /// Do other stuff in Async Method </code></pre> <p>Async method for doing the individual custom searches:</p> <pre><code>private async Task&lt;KeyValuePair&lt;string, List&lt;string&gt;&gt;&gt; GetCustomOptionList(string key, HttpClient client, SearchMetadata sm) { sm.OptionFieldName = key; var response = await HttpClientExtensions .PostAsJsonAsync(client, CatalogSpecificOptionPath, sm) .Result.Content.ReadAsStringAsync(); return new KeyValuePair&lt;string, List&lt;string&gt;&gt;(key, Newtonsoft.Json.JsonConvert .DeserializeObject&lt;List&lt;string&gt;&gt;(response)); }// end task </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload