我一直在尝试从我的条目类的多选择列表框中添加一些选定的项。
经过一些研究后,我发现这个解决方案是可行的:
EntityCollection<Publisher> entityCollection = new EntityCollection<Publisher>();
foreach (Publisher pub in this.publishersLst.SelectedItems)
{
entityCollection.Attach(pub);
}但即使它解决了我遇到的第一个问题,我现在也得到了一个新的问题。我似乎找不到解决办法..。我甚至试着分离那个实体,但没有运气。
我现在遇到的错误是:
当此
的所有者为null时,不允许进行RelatedEnd请求的操作。使用默认构造函数创建的RelatedEnd对象只应在序列化期间用作容器。
有人经历过这个问题吗?
谢谢。
发布于 2012-01-13 17:00:32
我用另一种方式解决了。
entry.Publishers = new EntityCollection<Publisher>();
foreach (Publisher item in this.publishersLst.SelectedItems)
{
entry.Publishers.Add(item);
}需要一份新的名单才能生效。
致以问候。
https://stackoverflow.com/questions/8766801
复制相似问题