locked
Custom method inside a DomainService: RRS feed

  • Question

  • I've a Custom Method inside my DomainService.

    [Custom]
    public void SetSth(Something sth, int value)
    {
      this.Context.Something.Attach(sth);
      sth.Value = value;
    }

    I can complie and see the method "SetSth" also in my Silverlight-App.
    But if i call my method, nothing happens. The breakpoint in SetSth is never reached.

    Do I miss something? Is this a Bug in RIA Services July?
    Or is there another way to access a server sider method in silverlight?

    Friday, August 21, 2009 3:51 AM

Answers

  • You have to call SubmitChanges on the domain context which actually triggers the roundtrip to the server. Not very intuitive, but hey, who are we ;-) Also notice that validation will be called (client and server side), before it reaches your custom method. So if any validation constraint is broken, you still won't hit the method.... Another example of something you wouldn't expect....

    Friday, August 21, 2009 7:39 AM

All replies

  • You have to call SubmitChanges on the domain context which actually triggers the roundtrip to the server. Not very intuitive, but hey, who are we ;-) Also notice that validation will be called (client and server side), before it reaches your custom method. So if any validation constraint is broken, you still won't hit the method.... Another example of something you wouldn't expect....

    Friday, August 21, 2009 7:39 AM
  • I was already able to solve the problem. But you descripe the solution perfectly. So I'll mark your answer as solution.

    Thank you

    Friday, August 21, 2009 9:29 AM
  • Would you please explain this some more?  I have the following method, but the parameters don't arrive from the Load method.

     public IQueryable<vwAltercations> GetAltercationSet(string sCase, string sAltercationID, string sProCon)

    Monday, September 7, 2009 3:38 PM
  • The SubmitOperation is used for saving data and invoking the custom operation. Somehow .NET RIA Services treats the custom operation as part of a save. The LoadOperation is something else and should be used to invoke a query method like yours. You have to pass the parameters, so on the client you have something like:

    // Compose the query request
    EntityQuery<vwAltercations> query = _context.GetAltercationSet( "somesCaseValue", "somesAltercationID", "somesProCon" );
    // Invoke the query and handle the response in the callback
    LoadOperation<vwAltercations> operation = _context.Load<vwAltercations>( query, OnGetAltercationSetCompleted, null);
    ...
    private void OnGetAltercationSetCompleted(LoadOperation<vwAltercations> operation)
    {

              

    Tuesday, September 8, 2009 2:45 AM