与父项一起编辑子实体 [英] edit child entity along with parent

查看:69
本文介绍了与父项一起编辑子实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个以0..1:1关系定义的实体。当我将表单和控件绑定到父实体时,我还想绑定到子实体,以便用户可以同时编辑所有字段。


一切都按预期工作  ;只要当我绑定到父实体时子实体已经存在。如果在加载父项时子项实体不存在,则对子实体的表单控件的更改不会根据需要自动创建/删除子项
。如果用户没有输入任何数据,我不想创建孩子。如果用户删除了所有数据,那么我想删除子项(显然不再需要)。如何以最少的代码以最简单的方式执行此操作?


我可以在检索父项时检查现有子项,如果它不存在,则创建它。但这并不能解决如果没有修改任何属性的问题,那么我不想将空子项保存到数据库中。


如果我创建了子项,将添加子项的状态,并将修改父项的状态。但是,如果用户没有对子表单字段进行任何更改,那么恢复关系状态和子节点的最佳方法是什么?

解决方案

< blockquote>

您好,


主 - 详细信息窗口是您想要的吗?

http://msdn.microsoft.com/en-us/data/ff706685.aspx


I have two entities defined with a 0..1:1 relationship. When I bind my form and controls to the parent entity, I also want to bind to the child entity so that the user can edit all the fields at the same time.

Everything works as expected as long as the child entity already exists when I bind to the parent. If the child entity doesn't exist when the parent is loaded, changes to the child entity's form controls do not automatically create/remove the child as needed. If user doesn't enter any data, I don't want to create the child. If user removes all data, then I want to remove the child (it's obviously no longer needed). How do I go about doing this in the easiest way with the least amount of code?

I can check for an existing child when retrieving the parent and if it doesn't exist, create it. But this doesn't solve the issue of if none of its properties were modified, then I don't want to save an empty child to the database.

If I create the child, the state of the child will be added and the state of the parent will be modified. But what is the best way to revert the state of the relationship and the child if the user doesn't make any changes to the child's form fields?

解决方案

Hello,

Is the master-detail window what you want?
http://msdn.microsoft.com/en-us/data/ff706685.aspx


这篇关于与父项一起编辑子实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆