I have a custom stored procedure in SQL Server that I would like to execute via RIA services. I have completed the Function Import with a scalar return type (int assuming stored proc returns the row count). I can see my stored procedure in my ObjectContext. I wrapped the stored proc in my RIA service, called from my Silverlight client. The client is calling the method "ApproveOrRejectLeave" in this example, but the server-side code is never getting executed. I even tried calling tmsService.SubmitChanges(), but nothing happens on the server-side.
Am I missing something?
Client Side:
EmpDomainContext tmsService = new EmpDomainContext();
tmsService.ApproveOrRejectLeave(leaveRequest);
Server Side:
public void ApproveOrRejectLeave(LeaveRequestView current)
{
ObjectResult result = this.ObjectContext.ApproveOrRejectLeave(current.EmpId, current.ReviewedByUserId, current.StatusId);
}
Thanks, Rav
I have found the reason!! All that is required is an [Invoke] attribute. RIA Services calls methods with [Edit], [Insert] and [Delete] attributes based on the EntityState (Modified, Inserted or Deleted respectively). Since my method doesn't have an action in specific and is a Stored Proc call, RIA is unable to locate any "valid" EntityState and doesn't call this server method. Decorading it with a [Invoke] attribute did the trick !!