如何绑定到 DomainService 上的 Invoke 操作?

发布于 2024-10-08 01:03:26 字数 380 浏览 1 评论 0原文

我正在修改 RIA 服务,并且创建了一个 DomainService,并且能够将其绑定到网格/数据表单等...但是对于我的一生,我看不到如何在上面调用自定义方法那个域服务。我创建了一个这样的方法:

[Invoke]
public IEnumerable<string> GetCities()
{
    return new List<string>() { "some city" };
}

我希望能够将组合框的项目集合绑定到该方法(单向)。

在 silverlight 页面中,有一个 peopleDomainService 对象,在将控件添加到用于绑定的页面时创建为资源。但我在上面找不到任何自定义方法。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柠檬 2024-10-15 01:03:26

您所描述的没有看到该方法的方式让我想知道您是否创建了 peopleDomainService 的实例,或者您是否只是引用自动放入 XAML 中的类定义。

只要您重建了 .Web 项目,这样的事情就应该可以正常工作。

peopleDomainService ldCTX = new peopleDomainService();
var query = ctx.GetCities();
ldCTX.Load( query, GetCities_Loaded, null );

并添加 GetCities_Loaded 事件来处理结果。

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.

泅人 2024-10-15 01:03:26

假设您的调用方法位于 FooDomainService 中,您可以这样称呼它:

fooDomainServiceInstance.Context.GetCities( (op) =>
{
  if (op.HasError)
  {
    // Handle error.
  }
  else
  {
   var data = ( op as InvokeOperation<IEnumerable<string>> ).Value;
   // Do something with the data...
  }
}, null);

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文