1

我在 SQL Server 中有一个自定义存储过程,我想通过 RIA 服务执行它。我已经完成了具有标量返回类型的函数导入(int 假设存储过程返回行数)。我可以在我的 ObjectContext 中看到我的存储过程。我将存储的过程包装在我的 RIA 服务中,从我的 Silverlight 客户端调用。在此示例中,客户端正在调用方法“ApproveOrRejectLeave”,但服务器端代码永远不会被执行。我什至尝试调用 tmsService.SubmitChanges(),但在服务器端没有任何反应。

我错过了什么吗?

客户端:

EmpDomainContext tmsService = new EmpDomainContext();
tmsService.ApproveOrRejectLeave(leaveRequest);

服务器端:

public void ApproveOrRejectLeave(LeaveRequestView current)
{
    ObjectResult result = this.ObjectContext.ApproveOrRejectLeave(current.EmpId, current.ReviewedByUserId, current.StatusId);
}

谢谢,拉夫

4

1 回答 1

1

我找到原因了!!所需要的只是一个 [Invoke] 属性。RIA 服务根据EntityState(分别为Modified、Inserted 或Delete)调用具有[Edit]、[Insert] 和[Delete] 属性的方法。由于我的方法没有特定的操作并且是存储过程调用,因此 RIA 无法找到任何“有效”EntityState 并且不会调用此服务器方法。用 [Invoke] 属性装饰它就可以了!

[Invoke]
    public void ApproveOrRejectLeave(LeaveRequestView current) {     ObjectResult result = this.ObjectContext.ApproveOrRejectLeave(current.EmpId, current.ReviewedByUserId, current.StatusId); } 
于 2012-01-25T07:32:07.607 回答