views:

186

answers:

1

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?

A: 

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.

Zied