使用存储过程从 EF4 返回嵌套复杂类型

发布于 2024-09-24 15:40:45 字数 642 浏览 1 评论 0原文

是否可以使用 EF 从多个不同的存储过程返回嵌套的复杂类型? (例如 ClientSelect、ClientAddressSelect)

我导入了一些存储过程并添加了函数导入,并为每个返回类型创建了一个复杂类型。 (例如客户端和客户端地址)。

例如,现在我想将 ClientAddress 复杂类型添加到 Client 复杂类型中。我将使用 ClientSelect 返回 Client 的所有值,然后使用 ClientAddressSelect 填充 ClientAddress。

当我尝试运行 ClientSelect 时,出现以下错误:

"Nested ComplexType property 'ClientAddresses' in the ReturnType 'Client' of the function 'myModel.ClientSelect' is not supported, please consider flattening the nested ComplexType property."

这使得这看起来不可能,是否有其他方法可以解决此问题?我正在使用 WCF RIA 服务,并且希望在将其发送到 Silverlight 客户端之前在服务器端填充完整的 Client 对象。

任何帮助/建议表示赞赏。

Is it possible to return nested complex types from multiple different Stored Procedures using EF? (e.g. ClientSelect, ClientAddressSelect)

I have imported a few stored procedures and added function imports and created a Complex Type for each of the return types. (e.g. Client and ClientAddress).

Now, for example, I want to add the ClientAddress Complex Type to the Client complex type. I will return all values for Client using ClientSelect and then populate ClientAddress using ClientAddressSelect.

When I try to run ClientSelect I get the following error:

"Nested ComplexType property 'ClientAddresses' in the ReturnType 'Client' of the function 'myModel.ClientSelect' is not supported, please consider flattening the nested ComplexType property."

Which makes it look like this isn't possible, is there another way round this? I'm using WCF RIA Services and would like to populate the full Client object on the server side before sending it to the Silverlight client.

Any help/suggestions appreciated.

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

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

发布评论

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

评论(2

缱绻入梦 2024-10-01 15:40:45

最新的 RIA Services SP1(刚刚作为 BETA 发布)现在支持复杂类型。您可能需要考虑它,因为我们发现它还解决了 RIA 服务的许多问题。

适用于 Silverlight 4 的 WCF RIA 服务 V1.0 SP1 Beta:
http://www.microsoft.com /downloads/en/details.aspx?FamilyID=330f6831-5b90-4315-b042-96127a4a7efc

WCF RIA 服务工具包 2010 年 10 月:
http://www.microsoft.com /downloads/en/details.aspx?FamilyID=a23325ef-7b1f-4c92-9fd5-ffee48f7c7bc

The latest RIA Services SP1 (just released as a BETA) now supports complex types. You might want to consider it as we found it also solves a number of problems with RIA services.

WCF RIA Services V1.0 SP1 Beta for Silverlight 4:
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=330f6831-5b90-4315-b042-96127a4a7efc

WCF RIA Services Toolkit October 2010:
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a23325ef-7b1f-4c92-9fd5-ffee48f7c7bc

旧时模样 2024-10-01 15:40:45

我通过将复杂类型声明添加到分部类中并使用 [Include] 和 [Associate] 属性解决了这个问题。

using System.ServiceModel.DomainServices.Server;
using System.ComponentModel.DataAnnotations;

public partial class Client
{
  [Include]
  [Association("Client_Address", "ClientAddressID", "ClientAddressID")]
  public IEnumerable<ClientAddress> Addresses { get; set; }
}

然后,我调用 SP 来填充 Client,然后调用单独的存储过程来填充 Client.Addresses

I resolved this issue by adding the Complex Type declaration into a partial class and using the [Include] and [Associate] attributes.

using System.ServiceModel.DomainServices.Server;
using System.ComponentModel.DataAnnotations;

public partial class Client
{
  [Include]
  [Association("Client_Address", "ClientAddressID", "ClientAddressID")]
  public IEnumerable<ClientAddress> Addresses { get; set; }
}

I then call a SP to populate Client, and then a seperate stored procedure to populate Client.Addresses

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