I'm trying to make a composite query using the BingSearchContainer.cs. The query itself is fine, but I can't access the results. There seems to be a problem with the IEnumerator:
// This is fine
var compositeResults = compositeQuery.Execute();
// Accessing the enumerator throws with:
// The closed type Bing.ExpandableSearchResult does not have a corresponding WebTotal settable property.
foreach (var result in compositeResults)
// or if I try this:
var x = compositeResults.GetEnumerator();
// then this statement throws
How do I access the results? In the above foreach loop, Intellisense shows that
result contains collection properties (result.Web, result.Image, etc) as I expected, but
compositeResults itself throws when I try to drill into it.
The app discussed in the blog entry does not do a composite query. At least I didn't see that. It makes an Image query and a Web query. All my singular queries (Web, Image, etc) work fine and I'm able to iterate the return object to display the individual
results. And my composite query (that is, the query itself) also works fine, but throws an exception when I iterate its results object.
Update: I downloaded BingSearchContainer.cs again and noticed that the new version now includes the property (and other properties) for ExpandableSearchResult that the exceptions I was getting were complaining about. The new version also
introduces breaking changes in its API - it adds new parameters in the bingContainer.Web, bingContainer.Image, etc. methods for setting options. That's good, but the method parms are now in a different order; so if you decide to use this new version
of BingSearchContainer, you'll have to update the places you're using it.
Sorry, looks like I misread your previous question (I thought you were looking for an example of how someone used BingSearchContainer.cs), but here's a follow up one.
When you are talking about the newer version, when did you last download the one that did not contain the ExpandableSearchResult properties? The BingSearchContainer.cs is auto-generated and describes the schema of the API, so if you downloaded the file
before we supported Composite, than indeed you would have such issues.
One thing to keep in mind is that when you new-up a service container instance, it has IgnoreMissingProperties == false so any change to the entity-set (even adding properties to it) would cause an exception in the code.
You could easily fix that by setting serviceContainer.IgnoreMissingProperties = true; after newing-up the instance before enumerating it.
var serviceContainer = new BingSearchContainer(new Uri("https://api.datamarket.azure.com/Bing/Search/v1/"));
serviceContainer.IgnoreMissingProperties = true;
serviceContainer.Credentials = new NetworkCredential("User", "AccountKey");
var compositeResult = serviceContainer.Composite("web", "xbox", null, null, null, null, null, null, null, null, null, null, null, null, null).Execute().First();
foreach (var result in compositeResult.Web)