IResult, POCO and Rest

Feb 22, 2011 at 7:32 PM
Edited Feb 22, 2011 at 7:32 PM

I am sure a similar question like this has already been asked, but I haven't found it. I am new to CM, so please forgive my ignorance. :)

I have a basic helper class which loads a URL into an XDocument and then deserializes into my POCOs. 

Now, the thing is, I should wrap this code in an IResult correct?

I have a SearchViewModel and it has a method called public IEnumerable<IResult> ExecuteSearch()

This would call my helper class?

In essence, I want something similar to GameLibary sample, however, I do not understand all the IQuery stuff.


Any help?

Feb 22, 2011 at 10:38 PM

IQuery, ICommand are interfaces representing the two kind of messages that the client send to the server through the IBackend interface.
This is the model of communication tipically used in Enterprise Service Bus architectures.

But... those interface are specific to the GameModel sample infrastructure; they are not related to CM's IResult. You don't need IQuery to use IResult.
IResult work well with asynchronous operation; since the IBackend interface is inherently asynchronous, IResult was the natural choice to implement.
This perhaps caused some confusion.

Your scenario involves an asynchronous operation, too; so you are right about wrapping your operation into an IResult.
You have to start the operation in the Execute method and raise the Completed event at completion.

In order to have the operation executed, the ViewModel should look like:

class SearchViewModel {

public IEnumerable<IResult> ExecuteSearch() {
  var loadResult = new MyLoadResult(...);
  yield return loadResult;

  var data = loadResult.LoadedData;
  //use the loaded data


Feb 23, 2011 at 1:41 PM

Thanks! I got it working :)