DomainService and Performing update ServerSide

8 posts, 0 answers
  1. Paul
    Paul avatar
    113 posts
    Member since:
    May 2009

    Posted 27 Feb 2012 Link to this post

    Hi,
        I have a OpenAccess DomainService that i use for Silverlight\RIA that works fine when requesting objects and Updating etc from Silverlight. What I want to achieve is the same functionality when I try to do some additional work in the DomainService.

    So say I have called a function in the DomainService from Silverlight that I want to do a query and then perform some updating on the results serverside. I know I can do this.DataContext.Assets.Where(etc..) to get my results on serverside and then I can loop those results on the serverside updating any fields and then do a this.CommitChanges() to save that back to the DB. I would like to though when doing the update make use of the UpdateAsset(Asset p) function that is already in the DomainService that I use for RIA. So how can I perform a query serverside that gets added to the changeset and then perform some updating on it so that when I want to commit those changes it will use the associated updatefuntion for that class like it would if I was updating the class from silverlight and calling submitchanges.

    Thanks
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 01 Mar 2012 Link to this post

    Hi Paul,

     In our RIA DomainService implementation the update methods to which you are referring are actually used as a callback methods after the real operation has finished (you can see the comment that gets generated with them). Having that in mind this might not be the best place to implement the logic you have in mind.

    Kind regards,
    Petar
    the Telerik team
    Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
  3. DevCraft banner
  4. Paul
    Paul avatar
    113 posts
    Member since:
    May 2009

    Posted 01 Mar 2012 Link to this post

    Hi Petar,
                 Yeah and I have created a herited class of your implementation so that my code will not get overwritten by your self generating code. What I want to be able to do from the server side is query an entity and place it in the change set and then modify it and call submit as if I were doing it from silverlight. That way I'm hoping it would then use the callback method.

    Thanks
  5. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 05 Mar 2012 Link to this post

    Hi Paul,

     You can create your own methods with the required logic and once you call the commit the callbacks should be called internally after the commit has finished.

    All the best,
    Petar
    the Telerik team
    Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
  6. Paul
    Paul avatar
    113 posts
    Member since:
    May 2009

    Posted 05 Mar 2012 Link to this post

    Hi Petar,
                  Thats the part I'm struggling to do or workout how to do. Could you provided me with an example of adding an enitiy to the changeset please.

    Thanks
    Paul
  7. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 08 Mar 2012 Link to this post

    Hello Paul,

      If I understood your scenario correctly you will need to expose the additional methods your require via the Invoke method attribute. This attribute is used when you need to implement operation that are exceeding the normal CRUD methods. Additional information can be found here.

    Regards,
    Petar
    the Telerik team
    Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
  8. Paul
    Paul avatar
    113 posts
    Member since:
    May 2009

    Posted 08 Mar 2012 Link to this post

    Petar,
             That's not what I'm after and perhaps what I'm asking is not possible. Lets say I used an invoke operation function called DeleteItem(int itemid) and in that function I delete an item but after in that same function I want to then query this.Datacontext.My_Entitys.where(p=>p.id==itemid) and in that returned collection I update a property of one of the entities. Calling this.commitchanges() will of course write that change back to the DB but I would like it to call the updatecallback function for that entity.

    My understanding is that I can create a new changeset and add the original entity in to it and then modify it so that when I call this.Submit(Changeset) the updatecallback for that entity will get called.

    So my goal is that once I'm in the DomainService class running at the server and the changeset is empty I can create a new one and add the entities I want to perform an operation on and submit that changeset while still in the Domainservice class at the server.

    Is that possible?
    Paul
  9. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 13 Mar 2012 Link to this post

    Hello Paul,

     I am afraid that this scenario is indeed not possible and I cannot provide you with any workaround because the functionality is simply not supported by the dataservices themselves.

    Kind regards,
    Petar
    the Telerik team
    Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
Back to Top
DevCraft banner