通过 Web 服务发送 Linq to SQL 类

发布于 2024-08-06 11:49:01 字数 272 浏览 1 评论 0原文

我有一个 Windows 应用程序和一个 Web 服务。两者都有一个带有 Customer 表的 Linq to SQL 映射器。来自同一个数据库的同一张表,一切都相同。我尝试将 winapp.Customer 对象发送到 Web 服务,但 webserviceReference.MyMethod() 接受 webservice.Customer 对象并且不接受 winapp.Customer 作为参数。尝试将 winapp.Customer 转换为 webservice.Customer 但也不起作用。有办法做到这一点吗?

I have a windows application and a web service. Both have a Linq to SQL mapper with Customer table on them. Same table from the same database, same everything. I tried to send winapp.Customer object to web service but the webserviceReference.MyMethod() accepts webservice.Customer object and doesn't accept winapp.Customer as parameter. Tried to cast winapp.Customer to webservice.Customer but didn't work either. Is there a way to accomplish this?

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

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

发布评论

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

评论(2

じ违心 2024-08-13 11:49:01

不,无法使用 ASMX Web 服务来完成此操作。它们要求代理类型和真实类型是不同的类型。

您可以使用 WCF 来完成此任务,尽管它打破了 SOA 的理念(客户端和服务器将通过公共类代码捆绑在一起)。

最后,使用任何类型的 Web 服务将 LINQ 传递到 SQL 或实体框架类都存在问题。当在层之间传递时,微软会搞乱并序列化依赖于实现的数据。当各层位于同一台计算机上时,这可能有意义,但当它们位于不同的计算机上时,意义就小得多。

No, there is no way to accomplish this using ASMX web services. They require that the proxy type and the real type be different types.

You can accomplish this using WCF, though it breaks the idea of SOA (the client and server will be tied together by the common class code).

Finally, there are problems with passing LINQ to SQL or Entity Framework classes using web services of any kind. Microsoft messed up and serializes implementation-dependent data when passing between tiers. This may make sense when the tiers are on the same computer, but makes much less sense when they are on different machines.

Oo萌小芽oO 2024-08-13 11:49:01

在您的 WinApp 中,您可能必须编写从 winapp.Customer 到 webservice.Customer 的显式转换。

In your WinApp, you'll probably have to write an explicit conversion from winapp.Customer to webservice.Customer.

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