Reputation: 17196
I'm tinkering with RIA Services and I've created a DomainService and I'm able to bind that to grids/dataforms and the like... but for the life of me I can't see how I can call custom methods on that DomainService. I've created a method like this:
[Invoke]
public IEnumerable<string> GetCities()
{
return new List<string>() { "some city" };
}
I want to be able to bind the items collection of a combobox to that method (one-way).
In the silverlight page, there is a peopleDomainService
object that is created as a resource when adding controls to the page that is used for binding. But nowhere on it can I find any of my custom methods.
Upvotes: 1
Views: 2014
Reputation: 4174
The way you are describing not seeing the method makes me wonder if you have created an instance of peopleDomainService or if you are just referring to the class definition that was automatically put into the XAML.
Something like this should work fine, as long as you've rebuilt the .Web project.
peopleDomainService ldCTX = new peopleDomainService();
var query = ctx.GetCities();
ldCTX.Load( query, GetCities_Loaded, null );
And add your GetCities_Loaded event to handle the result.
Upvotes: 1
Reputation: 1827
Assuming your invoke method is in the FooDomainService you'd call it so:
fooDomainServiceInstance.Context.GetCities( (op) =>
{
if (op.HasError)
{
// Handle error.
}
else
{
var data = ( op as InvokeOperation<IEnumerable<string>> ).Value;
// Do something with the data...
}
}, null);
Upvotes: 1