如何编写基于ria服务的求和计算?

发布于 2024-08-13 20:59:23 字数 289 浏览 2 评论 0原文

当对 SL 应用程序使用 ria 服务时,我可以发出以下异步调用来获取一组实体列表。

LoadOperation<Person> ch = 
this.AMSContext.Load(this.AMSContext.GetPersonQuery().Where(a => a.PersonID == this.performer.PersonID));

但我想得到一些计算,例如 sum(Commission)、sum(Salary),结果不是实体,只是一个标量值。我该怎么做?

When using ria service for SL app, I can issue following async call to get a group of entity list.

LoadOperation<Person> ch = 
this.AMSContext.Load(this.AMSContext.GetPersonQuery().Where(a => a.PersonID == this.performer.PersonID));

But I want to get some calculation, for example, sum(Commission), sum(Salary), the result is not entity, just a scalar value. How can I do this?

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

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

发布评论

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

评论(1

幻梦 2024-08-20 20:59:23

您可以使用通过WCF 方法返回任何值的方法。
在服务器端,您将拥有类似这样的内容

[EnableClientAccess()]
public class AMSContext : DomainService
{
   public float CalucalteCommissionSum()
   {
      // make your linq query and return the result here 
   }
}

,您可以像这样从客户端访问它:

this.AMSContext.CalucalteCommissionSum(x => context_CalucalteCommissionSumCompleted(x), null);

void context_CalucalteCommissionSumCompleted(System.Windows.Ria.InvokeOperation<float> op)
{
    // you will have the value in op.Value
}

检查 这个问题了解更多详细信息。

You could use methods that return any values with WCF methods.
On the server side you will have something like this

[EnableClientAccess()]
public class AMSContext : DomainService
{
   public float CalucalteCommissionSum()
   {
      // make your linq query and return the result here 
   }
}

And you can access it from the client like this :

this.AMSContext.CalucalteCommissionSum(x => context_CalucalteCommissionSumCompleted(x), null);

void context_CalucalteCommissionSumCompleted(System.Windows.Ria.InvokeOperation<float> op)
{
    // you will have the value in op.Value
}

Check this question for more details.

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