Last post Jul 30, 2012 01:40 PM by GA30
Jun 22, 2012 10:43 AM|GA30|LINK
In WCF RIA for SL, the code generation generates a DomainContext class. For each entity exposed by the DomainService server side, the DomainContext has a correponding EntitySet property client side. So, for example, if the DomainService exposes entities
A and B via methods GetAs and GetBs, then the DomainContext will have two properties, one called As and the other Bs, each one an EntitySet of the corresponding type. Now with upshot, I am wondering whether there is anything analogous to the DomainContext.
Obviously the ASP.NET DataController is analogous to the WCF RIA DomainService, I think. But how about the DomainContext? From what I have been able to tell, with upshot the client will work with a RemoteDataSource. But it appears the RemoteDataSource is limited
to a single entity. It also appears that the commitChanges method is invoked on the RemoteDataSource which is for a single entity. With WCF RIA, the CommitChanges is invoked on the DomainContext which can hold many different types of entities, and when invoked,
CommitChanges submits a changeset to the server with all the different types of entities changed, and on the server not only are all the changes but they can also be saved in a transaction safe unit of work manner. Is this possible with upshot? If RemoteDataSource
is in fact limited to a single entity and commitChanges is invoked at this level, how would I go about commiting changes for multiple entities from multiple remotedatasources and at the same time ensure a unit of work server side? Sorry, I am sure I am missing
some basic stuff here. Thank you
Jul 26, 2012 02:28 AM|KDegrave|LINK
I experimented a bit with RIA services and Upshot. I can tell you, upshot can handle multiple inserts, updates and deletes. It keeps track of the enities and when you commit it will fire update, insert and delete statements for all the entities that are
add, deleted or modified.
for an example take a look at my project
http://ria4htmldemo.codeplex.com/, I hope this gives you a better view.
Jul 27, 2012 07:36 AM|GA30|LINK
thanks for the answer kdegrave. it does not seem like much is going on around this forum so finally hearing a voice out there in response to my questions is great news!
anyway, i will have to look at your sample project, because from what I was able to tell each remotedatasource is for one type of entity. i understand that if i add, edit, or delete multiple entities of the type associated with the remote datasource, when
changes are saved a batch will be submitted with all the changed entities. but what about what if you need to add, edit, delete entities of ***DIFFERENT*** types from different remotedatasource instances all in one batch? i will take a look at your sample
to see how this works.
Jul 27, 2012 12:31 PM|KDegrave|LINK
I'm affraid I probably misunderstood your original question, but to awnser on it. I don't think you are able to update different types in one batch, but that don't mean you can't. You can for example add an commitChanges to your viewmodel that does a commitChanges
to different datasources.
If you are looking for an commit changes in a transaction, then I think I will have to disapiont you. As far as I know it isn't possible.
An other way to work is with child entities.
Hope this helps...
Jul 27, 2012 01:41 PM|ppavlov|LINK
I think this is critical, basic functionality. I hope it is planned and will be added soon (as soon as the "pause button" is released). It shouldn't be hard to implement.
Jul 27, 2012 03:30 PM|GA30|LINK
yeah, i am definitely looking for batch update within a transaction safe unit of work. that's what i figured. brad wilson wrote an interesting post on web api batch handler (http://bradwilson.typepad.com/blog/2012/06/batching-handler-for-web-api.html).
assuming upshot is not dead already and development continues once mvc 4 is released, i hope cross entity batch support is added.
when you say "An other way to work is with child entities.", do you mean work with aggregate roots/composites such that the root object and all the objects making up its composition are sent to the server on save?
Jul 28, 2012 07:25 AM|KDegrave|LINK
I think it is that.
You can make for example a container object, and this container objects keeps a list of persons and a list of orders,...
I think that should be possible.
I'm currently trying to setup a situation with a root and child elements.
P.S. I don't know how SL works with RIA services, but in SL do you have a transactional commit? or also a batch commit like here?
Jul 30, 2012 01:40 PM|GA30|LINK
yes, in SL we have transactional/batch commit. in a nutshell, in SL/RIA you can define these things called "domain services" which in the asp.net web api world are similar to datacontrollers. these are defined server side, and a domain service can have various
CRUD methods for different types of entities. then some code generation magic happens and the client SL app is given something known as a domaincontext, which basically is this sort of proxy/repository to the server side domain service. in upshot terms the
domaincontext is similar to the remotedatasource, and the code generation is analogous i guess to the upshot html helper method. so using this domaincontext, an SL client can manipulate (add/edit/delete) entities of different types and then submit all changes
in one batch using the domaincontext's submit method. then on the server one instance of the domain service is instantiated to handle all the changes. there are different data access flavors of domain services. there's one that's integrated with EF. there's
another that's plain vanilla and does nothing for you. either way, you can hook into the domain service pipeline (override methods) and ensure transactions. also, RIA supports both the aggregate and changeset models for saving changes. with the former, when
changes are made and submitted to any part of the aggregate, the entire aggregate is sent to the server, and only the aggregate root's domain service CRUD method is invoked. you then have to coordinate the persistance of all entities that make up the aggreate. whereas
with the changeset approach, when changes are submitted to the server, only the entities changes are sent to the server, and the CRUD domain service methods for each type of entity are invoked. that's a very oversimplication of what SL RIA does. it's super
powerful and really the only thing i miss about SL. i hope upshot comes close to doing what RIA does, and it already is close