如何使用 Ria 服务通过 EF 添加具有外键的实体?
我的数据库中有两个表:书籍和类别。在我的 EDMX 中,我生成了 Book 和 Category 类,以及相应的 BookSet 和 CategorySet。我创建了 BookService,并且可以通过 BookContext 在我的 SilverLight 代码中访问它。
通过 BookContext 我可以加载所有书籍的列表。我现在的问题是我正在尝试通过此上下文将一本书添加到我的数据库中。但是,当我尝试添加类别信息以满足外键约束时,我无法这样做。
我在 Google 上进行了广泛的搜索,但我无法看到如何使用 POCO 执行此操作的代码。有人可以帮忙吗?
提前致谢
I have two tables in my database: Books and Categories. In my EDMX I have generated classes Book and Category, and correspondingly BookSet and CategorySet. I created BookService and can access it in my SilverLight code via BookContext.
Through BookContext I am able to load a list of all books. My problem right now is I am trying to add a Book to my database via this context. However, when I try to add the category information to suffice the foreign key constraint, I am not able to do so.
I have searched Google far and wide but I am not able to see code for how to do this with a POCO. Can anyone assist?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很确定它会是这样的。
I'm pretty sure that it would be something like this.