mihies wrote:
- So, hypothetically, if Order entity contains changes, UoW will fetch its Customer entity but not OrderDetails. Or will it include OrderDetails, too?
UoW won't fetch anything. You can specify if a SAVED entity is refetched. that's it. Fetching related data is not the purpose of a uow, as that would mean a lot of concerns were grouped into a single class, which isn't always a good idea
- Yes, Save and Close. But sometimes it is convenient to leave the form open for further changes (i.e one often saves sources in VS.NET (becuase it crashes here and there ) and continue working without re-opening).
Then if you save, you've to refetch the data. Remoting isn't free nor transparent. It comes with a set of constraints, so you've to live with these. So if you send entities to the server, you've to be aware of the fact that the instances you have at the client are after that 'out-of-sync' and effectively have to be refreshed. best thing to do that is by re-starting the action, or better: design it in such a way that the action is restarted automatically.
Now, would this scenario work?
a) send UoW over the wire
b) save UoW with refetch
This is on the server, so unless you send the Uow back, you won't get the refetched data on the client!
c) loop through contained modified entities and extract Id, CuncurrencyField and store this pair + entity type. IOW save all EntityType,Id,ConcurrencyField triplet.
d) Return all these triplets to client.
e) update client entites (using entity type and id) with new concurrency values
f) set client entities as !IsDiry and !IsNew
You can swap EntityFields2 objects between entities of the same type:
myCustomer.Fields = myRefetchedCustomer.Fields;
et viola, myCustomer has the same fields . IsDirty is in that object. IsNew isn't.
c) I think UoW exposes the modified entities, right?
e) this should be straightforward using Context
f) what would be the proper way?
Context is an option. Though I still would opt for a simpler application design which streamlines this: if action is done, restart action, which automatically fetches the data for the action, which is up to date. Against popular FUD from some SOA fetisjists, SOA is something you have to design into your application: the communication between server and client isn't free nor transparent: it forces a given design upon you which affects the rest of the client application.