Note that there are some explanatory texts on larger screens.

plurals
  1. POmultiple deserialization of same object should or not create new instances?
    primarykey
    data
    text
    <p>In my scenario i've a <strong>MVC</strong> on iis serializing objects from entity framework where i've overridden <em>GetHashCode</em> and <em>Equal</em> methods since <strong>the Id of those objects is immutable once committed to the database.</strong><br> i also have some <strong>client, who can't reach the database</strong>, but connect to iis to get those entities serialized via json and deserialize them locally using newtonsoft.json.<br> When i deserialize them in the clients for a second time, to refresh the data in them, i was expecting the existing instances to be updated automatically.</p> <p>I'm expecting a little too much?<br> Should i write some clone method to copy properties and check a cache for existing ids?<br> Did i wrote something wrong in the <em>Equal</em> and <em>GetHashCode</em> methods?</p> <p>For instance:</p> <ol> <li>I've a blog entity with a title in the database</li> <li>The client connect to iis <ol> <li>get a json string containing {"Id" : 1, "Name" : "blogName"}</li> <li>deserialize it and store it locally</li> <li>add post to the blog in the same way to an observable collection in the class blog i've used client side</li> </ol></li> <li>Someone or something Change the blog name in the database</li> <li>The client try to refresh <ol> <li>get the json string containing {"Id" : 1, "Name" : "newBlogName"}</li> <li>deserialize it to a new instance of class blog, with same id</li> </ol></li> </ol> <p>What's next? copy the new instance name to the old one, ore there's a better way?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload