2012-01-24 40 views
1

我在SQL Server中有一個自定義存儲過程,我想通過RIA服務執行。我用標量返回類型完成了函數導入(int假定存儲過程返回行數)。我可以在我的ObjectContext中看到我的存儲過程。我將存儲過程包裝在我的RIA服務中,從我的Silverlight客戶端調用。客戶端在本例中調用方法「ApproveOrRejectLeave」,但服務器端代碼永遠不會執行。我什至嘗試調用tmsService.SubmitChanges(),但在服務器端沒有任何反應。RIA存儲過程 - 服務代碼沒有得到執行

我錯過了什麼嗎?

客戶端:

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

服務器端:

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

感謝, 單軌

回答

1

我已經找到了原因!所有需要的是[Invoke]屬性。 RIA服務根據EntityState(分別修改,插入或刪除)使用[編輯],[插入]和[刪除]屬性調用方法。由於我的方法沒有具體的操作,並且是一個Stored Proc調用,RIA無法找到任何「有效的」EntityState,也不會調用此服務器方法。用[Invoke]屬性對它進行裝飾就可以了!

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