Print Page | Close Window

Synchronizing Entities

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2779
Printed Date: 04-May-2024 at 2:37am


Topic: Synchronizing Entities
Posted By: gregweb
Subject: Synchronizing Entities
Date Posted: 17-Jun-2011 at 7:52pm
I have an interesting scenerio where an entity goes from the client, up to the server, is modified there (and saved to the database) and then comes back to the client.
 
The issue is that on the client, I now have two nearly identical entities; they are out of synch.  The first entity is in use, so I can't just remove it and replace it with the new instance.  The only solution I have come up with is to manually synch the changed properties, but I was wondering if there was any other guidance.
 
Greg



Replies:
Posted By: robertg
Date Posted: 20-Jun-2011 at 10:19am
Greg,
 
This sounds like a very interesting and strange problem. Is your entity in the client detached, or what? I don't understand why it would be a seperate entity from the one on the server. Would it be possible to make that entity a part of your EM in the first place, so you can keep it up to date with whatever changes you've made on the server by using a DataSourceThenCache merge strategy, which will overwrite the client-side version of the data with whatever is retrieved from the server-side?
 
Yours,
Robert


Posted By: gregweb
Date Posted: 21-Jun-2011 at 6:14am
Hi Robert,
 
Let me try to explain a bit better. 
 
On the client, I have an entity called EmailFolder.  I take this an pass it up to the Server and do some processing there to get new email.  One of the properties is called NumberOfNewEmails.  I set this property while on the server.  I then pass back the entire entity to the Client so that I know the number of new Emails.  Here is where the problem resides.  I can't add it back into the EntityManager as the original is already in the EntityManager so my only choice is to find the original and update the NumberOfNewEmails property using the copy.
 
In any case, don't worry about this too much, I got this working well enough to move along!
 
Greg



Print Page | Close Window