Remoting & ORMEntityOutOfSyncException

Posts   
 
    
Paddy
User
Posts: 20
Joined: 07-Jun-2007
# Posted on: 20-Jul-2007 16:11:23   

Hello there, how are you today?

So, here we go: Is there any way (without us changing flags, DBValue's, etc. manually) to save an entity and continue to use it?

Here's is the scenario:

  1. Client creates 'EntityA'
  2. 'EntityA' ID is created client side (let's say a GUID) so no need to fetch anything at server side is necessary.
  3. A remoting call to save 'EntityA' is made
  4. Client continue to use same 'EntityA' reference it had before the remoting call.

Actually, point number 4 will not work (ORMEntityOutOfSyncException), so again is there a way to avoid this behavior or are you planning to support it later?

And passing the entity back is out of the question: Serializing/marshalling a big object graph and sending it through the wire is a time consuming task!

If there's no way, ok we will do it; I just want to avoid reinventing the wheel if someone has already invented it simple_smile

Thank you very much.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 20-Jul-2007 16:44:36   

So, here we go: Is there any way (without us changing flags, DBValue's, etc. manually) to save an entity and continue to use it?

Use the following: myEntity.Fields.State = EntityState.Fetched;

It's added in v.2.5 currently in beta:

It's now possible to mark entities which are saved directly as 'Fetched' when they're not re-fetched. By default entities which aren't refetched and which are saved successfully will get the state 'OutOfSync'. To mark any successfully saved entity as 'Fetched', add an appSettings element which adds the key "markSavedEntitiesAsFetched" with a value 'true', or set the EntityBase(2).MarkSavedEntitiesAsFetched static property to true.

Paddy
User
Posts: 20
Joined: 07-Jun-2007
# Posted on: 20-Jul-2007 17:42:58   

Super! Many Thanks Walaa.

mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 20-Jul-2007 21:23:40   

Walaa wrote:

So, here we go: Is there any way (without us changing flags, DBValue's, etc. manually) to save an entity and continue to use it?

Use the following: myEntity.Fields.State = EntityState.Fetched;

It's added in v.2.5 currently in beta:

It's now possible to mark entities which are saved directly as 'Fetched' when they're not re-fetched. By default entities which aren't refetched and which are saved successfully will get the state 'OutOfSync'. To mark any successfully saved entity as 'Fetched', add an appSettings element which adds the key "markSavedEntitiesAsFetched" with a value 'true', or set the EntityBase(2).MarkSavedEntitiesAsFetched static property to true.

Will this also unset the dirty flags, copy Value into DBValue, etc?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 20-Jul-2007 21:44:10   

No, as there's no way the client will know what happened. It just sends the entity to the server. So there's no signal coming back to the client 'this happend to the entity'. I first thought of implementing what you describe but that wasn't possible. So this feature added to v2.5 is for people who don't want to fetch the entity again on the machine where it is saved.

Frans Bouma | Lead developer LLBLGen Pro
mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 20-Jul-2007 23:26:55   

Otis wrote:

No, as there's no way the client will know what happened. It just sends the entity to the server. So there's no signal coming back to the client 'this happend to the entity'. I first thought of implementing what you describe but that wasn't possible. So this feature added to v2.5 is for people who don't want to fetch the entity again on the machine where it is saved.

Out of curiousity, what do you mean by saying that it isn't possible? By that do you mean that calculated fields, identity fields, fields affected by triggers etc..., won't have their correct values? Or do you mean if a save failed (because that could be notified by an exception bubbling back to the client).

Because we've actually written a "Fake a Refetch" method which seems to work fine which does what I described before.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 20-Jul-2007 23:41:42   

With 'not possible' I meant: doing it automatically. There's no point in time on the client where the entity can be marked 'fetched', as the client code doesn't know what happens on the server.

So of course, one can call a method themselves on the client which makes the entity appear to be 'fetched' but it can't be originating from within the entity itself, as that's not possible, the entity itself doesn't know when what happens on the server.

Frans Bouma | Lead developer LLBLGen Pro