从 MVC 应用程序引用 DomainService 类?

发布于 2024-10-01 14:50:47 字数 369 浏览 0 评论 0原文

我们有典型的 Silverlight 和 Silverlight.Web 应用程序,它们通过 WCF RIA 服务连接在一起。我们已将 MVC 项目添加到解决方案中,并且不想编写在 DomainService 类中为我们创建的所有方法(所有插入、更新、删除等)。当我们从 MVC 项目引用 .Web 项目时,我们可以像往常一样访问 DomainService 类,但是当我们尝试使用 Update/Insert 方法进行更改时,问题就出现了。我想这与 Visual Studio 在 Silverlight 应用程序中自动生成 .g.cs 文件、创建 DomainContext 部分类有关。

有没有什么方法可以使用从外部项目在 .Web 项目中自动生成的 DomainService 并让它对实体进行更改?

We have the typical Silverlight and Silverlight.Web application that are hooked together through WCF RIA Services. We've added an MVC project to the solution and don't want to have to write all the methods that were created in the DomainService class for us (all the inserts, updates, deletes, etc.). When we reference the .Web project from the MVC project, we can access the DomainService class like usual, but the problem comes when we try to do changes using the Update / Insert methods. I imagine this has to do with Visual Studio auto generating the .g.cs file in the Silverlight application, creating the DomainContext partial class.

Is there any way to use the DomainService that has been autogenerated in the .Web project from external projects and get it to make changes to the entities?

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

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

发布评论

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

评论(2

凉薄对峙 2024-10-08 14:50:47

我认为您需要创建对其的服务引用。这将创建与 Silverlight 客户端中相同的包装器(或多或少)。

或者,您可以重构 DomainService 之外的所有 CRUD 逻辑,并将其放入 Web 项目以及 MVCC 应用程序引用的类库中。

I think you need to create a service reference to it. This will create the same wrappers (more or less) that you have in the Silverlight client.

Alternatively, you can refactor all the CRUD logic out of the DomainService and put it in a class library that is referenced by the Web project, as well as your MVCC app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文