Howto:添加新对象并将其保存到集合中 [英] Howto: Adding and Saving a new object to a collection

查看:60
本文介绍了Howto:添加新对象并将其保存到集合中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图弄清楚(不成功)如何使用WCF DataServices完成此方案。

I'm trying to figure out (unsuccessfully) how to accomplish this scenario with WCF DataServices.

 

I拥有我从WCF DataService加载的Customer对象,并为Orders扩展。

I have Customer object that I loaded from my WCF DataService with the expand on for the Orders.

然后我想做这样的事情:

I then want to do something like this:

客户.Orders.Add(new Order(){.... fields ...});

customer.Orders.Add(new Order(){....fields...});

然后让WCFDataService将新项目看到子对象的集合并执行相应的操作插入。

then have the WCFDataService see that new item to the collection off the subobject and do the appropriate insert.

 

这可能吗? 如果是这样,任何正确方向的指针都会非常有用。

Is that possible?  If so, any pointers in the right direction would be extremely helpful.

 

我已经尝试过使用context.UpdateObject(客户) );无效。

I've already tried using the context.UpdateObject(customer); to no avail.

推荐答案

Microsoft最近更新了有关WCF数据服务的文档,尤其是有关查询和更新的文档。请先阅读这些页面。我相信他们会提供你想要的答案。我只想说,你走在正确的轨道上。

Microsoft has recently updated the documentation on WCF Data Services, especially on querying and updating. Please read those pages first. I'm sure they'll provide the answers you want. Suffice to say, your on the right track.

http:/ /msdn.microsoft.com/en-us/library/dd756361.aspx

需要注意的一点是,在Silverlight中,生成的代理类将使用DataServiceCollection实体关系。这些的美妙之处在于您不必明确地调用AddObject()和AddRelatedObject()。

One thing to notice is that in Silverlight, the generated proxy classes will use the DataServiceCollection for all entity relationships. The beauty of those is that you don't have to explictly call AddObject() and AddRelatedObject().


这篇关于Howto:添加新对象并将其保存到集合中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆