WCF RIA 服务 - 返回两个已定义类的自定义类

发布于 2024-09-28 15:07:19 字数 575 浏览 1 评论 0原文

我有一个使用 EF 4 的 Silverlight / WCF RIA 服务应用程序。当前,有一个域服务返回两种类型的类:OrderItem 和 Event。我想创建一个包含这两项的类,以便在 XAML 级别更轻松地操作数据。组合这两个类的类如下所示:

[Serializable]
[DataContract]
public partial class EventOrderItem  {
    [Key]
    [DataMember]
    public string EventOrderItemKey { get { return Event.EventID.ToString() + "-" + OrderItem.OrderItemID.ToString(); } }

    [DataMember]
    public Event Event { get; set; }

    [DataMember]
    public OrderItem OrderItem { get; set; }
}

域服务返回 EventOrderItem,但该类中不存在 Event 和 OrderItem 属性。我如何让 RIA 服务获取这两个属性?

I have a Silverlight / WCF RIA Services application that uses EF 4. Currently, there is a domain service that returns two types of classes, OrderItem and Event. I'd like to create a class that contains both of these items for easier manipulation of the data at the XAML level. Here is what the class that combines the two classes looks like:

[Serializable]
[DataContract]
public partial class EventOrderItem  {
    [Key]
    [DataMember]
    public string EventOrderItemKey { get { return Event.EventID.ToString() + "-" + OrderItem.OrderItemID.ToString(); } }

    [DataMember]
    public Event Event { get; set; }

    [DataMember]
    public OrderItem OrderItem { get; set; }
}

The domain service returns the EventOrderItem, but the Event and OrderItem properties are not present on the class. How do I get RIA Services to pick up on these two properties?

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

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

发布评论

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

评论(2

胡渣熟男 2024-10-05 15:07:19

根据您的评论,不幸的是这是不可能的(这是我对 RIA 服务最大的困扰之一)。根据 RIA Services UserVoice 站点 (http://dotnet.uservoice.com/forums/57026-wcf-ria-services),他们现在正在致力于启用复杂类型,但目前您运气不佳: (。

希望这有帮助......

克里斯

As per your comment, unfortunately it's not possible (it's one of my biggest bugbears with RIA Services). According to the RIA Services UserVoice site (http://dotnet.uservoice.com/forums/57026-wcf-ria-services) they're working on enabling complex types now, but for the time being you're out of luck :(.

Hope this helps...

Chris

若能看破又如何 2024-10-05 15:07:19

我已经通过使用 [包含][Association] 所包含类型的属性。不过,我使用的是 POCO 对象而不是 EF4,因此您的情况可能会有所不同。

I've managed to get this working in a similar scenario in my application by making use of the [Include] and [Association] attributes on the included types. I'm using POCO objects instead of EF4, though, so your mileage may vary.

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