none
How do I get a BusinessSearchResult object?? RRS feed

  • Question

  • I'm using SOAP Services Bing Search Service in Silverlight Windows Phone 7 using C#...

    When I instantiate a search request and call the service as so...

    Bing.Search.SearchRequest  mySearchRequest = new Bing.Search.SearchRequest();
    .
    .  other work
    .
    mySearchService.SearchAsync(mySearchRequest);

    The completed event gives me back a Bing SearchResponse object that contains a result set that contains little info about the businesses I asked for (ID, location, Name).  What I want back is a BusinessSearchResult object.

    My question is: what do I have to do to get a BusinessSearchResult object?  I have tried casting to no avail.  The docs on the BusinessSearchResult tell all about it but not how to get the results.

    Thanks,
    Dean


    .net Developer
    • Moved by Ricky_Brundritt Friday, March 9, 2012 5:28 PM (From:Bing Maps: Map Control and Web services Development)
    Thursday, January 27, 2011 11:38 PM

Answers

  • It's pretty straight forward to get a BusinessSearchResult. here is an example of how to do it:

    public 	BusinessSearchResult GetBusinessSearchResult(location, keyword)
    {
    	SearchRequest searchRequest = new SearchRequest();
    
    	// Set the credentials using a valid Bing Maps Key
    	searchRequest.Credentials = new Credentials()
    	{
    		ApplicationId = "Your_Bing_Maps_Key"
    	};
    	searchRequest.StructuredQuery = new StructuredSearchQuery()
    	{
    		Location = location,
    		Keyword = keyword
    	};
    
    	//Make the search request 
    	SearchServiceClient searchService = new SearchServiceClient();
    	SearchResponse searchResponse = searchService.Search(searchRequest);
    
    	if (searchResponse.ResultSets[0].Results.Length > 0)
    	{
    		BusinessSearchResult bsr = searchResponse.ResultSets[0].Results[0] as BusinessSearchResult;
    		return bsr;
    	}
    	
    	return null;
    }



    Windows Live Developer MVP - http://rbrundritt.spaces.live.com | http://inknowledge.co.uk
    Tuesday, February 1, 2011 12:25 PM

All replies

  • It's pretty straight forward to get a BusinessSearchResult. here is an example of how to do it:

    public 	BusinessSearchResult GetBusinessSearchResult(location, keyword)
    {
    	SearchRequest searchRequest = new SearchRequest();
    
    	// Set the credentials using a valid Bing Maps Key
    	searchRequest.Credentials = new Credentials()
    	{
    		ApplicationId = "Your_Bing_Maps_Key"
    	};
    	searchRequest.StructuredQuery = new StructuredSearchQuery()
    	{
    		Location = location,
    		Keyword = keyword
    	};
    
    	//Make the search request 
    	SearchServiceClient searchService = new SearchServiceClient();
    	SearchResponse searchResponse = searchService.Search(searchRequest);
    
    	if (searchResponse.ResultSets[0].Results.Length > 0)
    	{
    		BusinessSearchResult bsr = searchResponse.ResultSets[0].Results[0] as BusinessSearchResult;
    		return bsr;
    	}
    	
    	return null;
    }



    Windows Live Developer MVP - http://rbrundritt.spaces.live.com | http://inknowledge.co.uk
    Tuesday, February 1, 2011 12:25 PM
  • I've been away on another project since my original post (why is this font so tiny?)

    But YES that worked when converted to WP7 WCF code.

    Thank you for your help.

    Dean


    .net Developer
    Thursday, May 12, 2011 11:38 PM