This is a migrated thread and some comments may be shown as answers.

DomainService and Performing update ServerSide

7 Answers 59 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Paul
Top achievements
Rank 1
Paul asked on 27 Feb 2012, 02:15 PM
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

7 Answers, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 01 Mar 2012, 09:53 AM
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 >>
0
Paul
Top achievements
Rank 1
answered on 01 Mar 2012, 10:54 AM
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
0
PetarP
Telerik team
answered on 05 Mar 2012, 06:04 PM
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 >>
0
Paul
Top achievements
Rank 1
answered on 05 Mar 2012, 06:10 PM
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
0
PetarP
Telerik team
answered on 08 Mar 2012, 04:38 PM
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 >>
0
Paul
Top achievements
Rank 1
answered on 08 Mar 2012, 06:04 PM
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
0
PetarP
Telerik team
answered on 13 Mar 2012, 12:42 PM
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 >>
Tags
General Discussions
Asked by
Paul
Top achievements
Rank 1
Answers by
PetarP
Telerik team
Paul
Top achievements
Rank 1
Share this question
or