CHI TANG
CHI TANG

Reputation: 93

Get RIA WCF domain service returned 'OUTPUT' parameter

On my MVVM Silverlight application I need to call Domain service function to get both sql query result and some 'OUTPUT' data from stored procedure. I figure out how to get the data on Domain Service side but on client I don't know how to get the 'OUTPUT' parameters from the function since Silverlight is async call. The following is my function on Domain Service and I need get the two returned OUTPUT parameters from the async call.

Thanks for any help.

CK

  [Invoke]
    public IEnumerable<sp_Inquiry_Result> GetResultAsync( string ID, 
                                                          out string sDescription, 
                                                          out float fvariance)
    {

        // Declare ObjectParameter object to store output param
        ObjectParameter WorkcenterDescription = new ObjectParameter("@Description", typeof(string));         
        ObjectParameter Variance = new ObjectParameter("@Variance", typeof(float));

        // Call stored procedure, passing in Object Parameter
        ObjectResult < sp_WorkcenterCostInquiry_Result > o = this.ObjectContext.sp_Inquiry(
            workcenterID, 
            Variance);

        // ObjectParameter will have output param value from stored proc
        sDescription = Convert.ToString(Description.Value);
        fvariance = (float)Convert.ToDouble(Variance.Value);

        return o.ToList().AsEnumerable();

    }

Upvotes: 0

Views: 1213

Answers (1)

iCollect.it Ltd
iCollect.it Ltd

Reputation: 93611

RIA Services dos not support out parameters. They would not make any sense to an asynchronous call (any out results are being ignored behind the scenes of the service call).

The standard approach is create a result object containing multiple properties and return that instead.

In your specific example that would been a new return type that includes these properties:

  • sp_Inquiry_Result
  • sDescription
  • fvariance

Upvotes: 1

Related Questions