将 EntityObject 映射到 POCO 并映射回 WCF RIA 服务会导致重复的子实体

发布于 2024-12-23 05:12:37 字数 714 浏览 3 评论 0原文

我创建了一个完整的 Visual Studio 2010 解决方案,可以在此处重现该问题:

http://dl。 dropbox.com/u/42317133/WcfRiaAutoMapper.zip

  1. 构建解决方案。
  2. 在测试项目中运行单元测试来部署数据库。
  3. 调试 SilverlightApplication1 项目
  4. 单击“Click me”按钮。
  5. 请注意,当只需要一名作者时,却将两名作者添加到作者数据库表中。

在“RIAServicesLibrary1.Web”项目中的BlogService.cs 中的InsertPost 方法映射期间存在问题。

如果我注释掉这两行,那么它就会按预期工作。

有什么想法吗?

AutoMapper 1.1 和 AutoMapper 2.0.0 都会发生这种情况,

非常感谢。

这是此处提交的问题的重新发布:
https://github.com/AutoMapper/AutoMapper/issues/165

I created a complete Visual Studio 2010 solution that can reproduce the issue here:

http://dl.dropbox.com/u/42317133/WcfRiaAutoMapper.zip

  1. Build the solution.
  2. Run the unit test in the test project to deploy the database.
  3. Debug the SilverlightApplication1 project
  4. Click on the "Click me" button.
  5. Notice that two Authors are added to the Authors database table when only one was expected.

The problem exists during the mapping in the InsertPost method in BlogService.cs in the "RIAServicesLibrary1.Web" project.

If I comment those two lines out, then it works as expected.

Any ideas?

This happens with both AutoMapper 1.1 and AutoMapper 2.0.0

Thank you very much.

This is re-post of the issue submitted here:
https://github.com/AutoMapper/AutoMapper/issues/165

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜清冷一曲。 2024-12-30 05:12:37

我终于能够通过使用 UseDestinationValue 成员选项解决此问题,如下所示:

Mapper.CreateMap<Post2, Post>().ForMember(destinationMember => destinationMember.Author, memberOptions => memberOptions.UseDestinationValue());

I was finally able to resolve this by using the UseDestinationValue member option as follows:

Mapper.CreateMap<Post2, Post>().ForMember(destinationMember => destinationMember.Author, memberOptions => memberOptions.UseDestinationValue());
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文