I've got a serious problem with Entity Framework 4.0 with deleting objects.
I would like to have a possibility on my client to create MyObject with all children connected to it and then operate on it. I mean add children, remove children and so on, and when I finish working with that simply save it on my Context.
Then I would like to get it from my Context, add something, remove something and than save it again.
Does selfTracking enables this?
I am already not able to do it :/ I invoke startTracking and so on, but each time I Apply changes on the context it wants to add everything as new object. Thanks for any hint.
Check with Following code,
object originalItem;
EntityKey key = ObjectContext.CreateEntityKey(entityName, entity);
if (ObjectContext.TryGetObjectByKey(key, out originalItem)) {
ObjectContext.ApplyCurrentValues(key.EntitySetName, entity);
}
ObjectContext.SaveChanges();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.