RIA POCO 中的嵌入对象?
向所有 silverlight 爱好者提一个简单的问题..
我需要通过 ria 服务公开一个自定义 POCO 对象.. 好吧,我可能可以通过普通的 Web 服务来完成它.. 所以我不介意你告诉我通过非 RIA 服务来完成它
有点像这样:
public partial class Monkey
{
// etc..
// This is an entity framework entity
}
public class MonkeyCollection
{
// This is the POCO
public string MonthName { get; set; }
public Monkey MonkeyForMonth1 { get; set; }
public Monkey MonkeyForMonth2 { get; set; }
// Keep RIA services quiet about the lack of a "key"
[Key]
public int ID { get; set; }
}
// In my service class
public IEnumerable<MonkeyCollection> GetMonkeys()
{
// Churn the data like butter
}
这返回 POCO 的集合,但它不返回嵌入对象(猴子)。
即它返回基元(月份名称,id),但不返回自定义对象。
事实上,Visual Studio 中的智能感知似乎甚至不知道类上的这些属性。
我应该做什么?
谢谢
丹尼尔
Quick question for all y'all silverlight buffs..
I need to expose a custom POCO object through ria services.. Well kind of, i could probably get away with doing it over a vanilla web service.. so i dont mind if you tell me to do it over a non-RIA service
It's a bit like this:
public partial class Monkey
{
// etc..
// This is an entity framework entity
}
public class MonkeyCollection
{
// This is the POCO
public string MonthName { get; set; }
public Monkey MonkeyForMonth1 { get; set; }
public Monkey MonkeyForMonth2 { get; set; }
// Keep RIA services quiet about the lack of a "key"
[Key]
public int ID { get; set; }
}
// In my service class
public IEnumerable<MonkeyCollection> GetMonkeys()
{
// Churn the data like butter
}
This returns a collection of the POCO's but what it doesn't return is the embedded objects (monkey).
i.e. it returns the primitives (monthname, id) but not the custom objects..
And in fact intellisense in visual studio doesnt even seem to know about those properties on the class..
What should i do?
Thanks
Daniel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要 IncludeAttribute 和 AssociationAttribute。
请参阅此处了解类似案例和说明。
另请检查 WCF RIA 服务和 DTO 关联 了解更多详细信息。
You need the IncludeAttribute and the AssociationAttribute.
Look here for a similar case and the explanation.
Also check WCF RIA Services and DTO with association for more details.
将其移至自己的网络服务中..感觉更干净!
Moved it into it's own web service.. Just feels cleaner!