Silverlight WCF服务存储过程

时间:2013-04-17 15:03:29

标签: vb.net wcf silverlight stored-procedures

我试图弄清楚如何从我的Silverlight应用程序调用存储过程。我可以使用这个函数调用数据库:

<OperationContract()>
Public Function ImportData(
    ByVal authentication As AuthenticationArgs,
    ByVal caseID As String) As ResponseArgs(Of GetGuidelineData_Result)

    Dim guidelineDataResults As GetGuidelineData_Result
    Dim exception As ExceptionArgs = Nothing

    If AuthenticationService.CheckPermissions(authentication, exception, PermissionType.StateUser) Then

        Try
            Dim model As DCF_ACCESS_Model = DataHelper.CreateDCF_ACCESS_Model()

            model.GetGuidelineData(caseID)

        Catch ex As Exception

            Return New ResponseArgs(Of GetGuidelineData_Result)(New ExceptionArgs(ex.Message))

        End Try

        Return New ResponseArgs(Of GetGuidelineData_Result)(guidelineDataResults)

    Else

        Return New ResponseArgs(Of GetGuidelineData_Result)(exception)

    End If

End Function

如何修改代码以调用存储过程呢?存储过程GetGuidelineData将1个参数作为输入。

1 个答案:

答案 0 :(得分:0)

我能够弄清楚如何使用以下内容调用存储过程:

<OperationContract()>
Public Function ImportData(
    ByVal authentication As AuthenticationArgs,
    ByVal caseID As String) As ResponseArgs(Of GetGuidelineData_Result)

    Dim guidelineDataResults As GetGuidelineData_Result
    Dim exception As ExceptionArgs = Nothing

    If AuthenticationService.CheckPermissions(authentication, exception, PermissionType.StateUser) Then

        Try
            Dim model As DCF_ACCESS_Model = DataHelper.CreateDCF_ACCESS_Model()

            ' Call stored procedure
            guidelineDataResults = model.GetGuidelineData(caseID).First()

        Catch ex As Exception

            Return New ResponseArgs(Of GetGuidelineData_Result)(New ExceptionArgs(ex.ToString()))

        End Try

        Return New ResponseArgs(Of GetGuidelineData_Result)(guidelineDataResults)

    Else

        Return New ResponseArgs(Of GetGuidelineData_Result)(exception)

    End If


End Function

对存储过程的调用是通过以下方式完成的:

 model.GetGuidelineData(caseID).First()

它获取集合中的第一个元素并将其作为输出返回。