views:

23

answers:

2

i have such code

 var menu = _dataManager.Menu.Details(id);
        var menu2 = _dataManager.Menu.Details(id);

        menu.Name = "AAA";

in this case menu2.Name will be "AAA", i guess it because of reference, but how can i solve it?

A: 

Entity lazy loads data. Force the load and disconnect it from the Model and then it will not be AAA.

Eager load:

DataLoadOptions op = new DataLoadOptions();
op.LoadWith<Details>(x => x.Menu);
//etc...
_dataManager.LoadOptions = op;

Update: It appears that in the past I disconnect by copying the data out to a non-entity POCO.

Russell Steen
any code sample?
kusanagi
yeah, trying to find the code for the last time i did this. reading any property should force the load. Disconnecting is more specific.
Russell Steen
Good answer Russell. It got me searching for a way to force an Enumeration on IEnumerable objects. I'm looking now but I dont think there's an Enumerate() method or anything. Would be nice in this context.
Jamie Dixon
A: 

Most likely the Details method is set to return a single instance of the menu item regardless of how many times you put it into different variable names.

One solution would be to use a different dataManager object for the second menu item.

Jamie Dixon