Question

I use ADO.NET Entity-Framework, I have a page that is data-bound to an entity variable in the code file.

The hierarchy of the item is Person.Orders I want the user to add/remove orders to this Person entity (Person.Orders.Add(order)), The problem is that while the entity is not saved yet, once the user makes a post back, the variables are disposed and the person and all its orders are gone. What should be a good practice on saving entities/variables (complex ones) in cache/memory/state or whatever (not save in the store, i want to save items in the store only when the user clicks the general Accept Changes btn, meanwhile i wanna build the hierarchy on the air)?

If I am not clear enough I will provide more details tomorrow, please accept my apology.

Was it helpful?

Solution

Use session state to keep your object hierarchy while you expect several action on the client and load your entities on each view reload. This way you'll reflect user changes and you'll keep them in memory 'till the final action is triggered at which point you'll probably save the entire entity hierarchy.

But be aware of the appdomain being unloaded in the middle of your user's job if you're using inproc session.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top