如何获取并设置自我跟踪实体列表 [英] how ti get and set a list of self tracking entities
问题描述
对于自我跟踪权限,我可以找到加载实体及其依赖项的场景示例,进行更改和更新。
我有一些场景,其中有一些对象是以表单形式加载更改了多个对象中的内容,并将更改保存到数据库中。这似乎没有直接起作用。
有谁知道怎么做?
您可以在此处看到更新并保存自我跟踪实体的WPF示例:http://msdn.microsoft.com/en-us/library/ee789839 (VS.100).aspx (最后一个示例)。
保存对象后,需要在每个实体上调用AcceptChanges。
            //保存所有部门及其课程。 跨度>
            foreach (var部门在部门)
  ;      {
                service.UpdateDepartment(省);
                //对所有对象调用AcceptChanges     //重置更改跟踪器并将对象的状态设置为"未更改"。   ;        department.AcceptChanges();
                foreach (var course in department.Courses)
;               course.AcceptChanges();
            }
如果这不是您要查找的信息,请告诉我。
谢谢,
朱莉娅
For self tracking entitites I can find examples for scenarios of loading an entity along with its dependencies, making changed and updating.
I have scenarios where a lit of aobjects is loaded in a form changes a made in several of the objects and the changes are saved to the database. This doesn't seem to work straight forward.
Does anyone know how to do this?
Hi,
you can see the WPF example that updates and saves the self-tracking entities here: http://msdn.microsoft.com/en-us/library/ee789839(VS.100).aspx (the last example).
After you save the objects you need to call AcceptChanges on each entity.
// Save all the departments and their courses.
foreach (var department in departments)
{
service.UpdateDepartment(department);
// Call AcceptChanges on all the objects
// to resets the change tracker and set the state of the objects to Unchanged.
department.AcceptChanges();
foreach (var course in department.Courses)
course.AcceptChanges();
}Please let me know if this is not the information you were looking for.
thank you,
Julia
这篇关于如何获取并设置自我跟踪实体列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!