WCF RIA 服务 - 返回两个已定义类的自定义类
我有一个使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您的评论,不幸的是这是不可能的(这是我对 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
我已经通过使用 [包含] 和 [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.