列表到实体集合
我一直在尝试从我的入门类的多选列表框中添加一些选定的项目。
经过一番研究,我发现这个解决方案可行:
EntityCollection<Publisher> entityCollection = new EntityCollection<Publisher>();
foreach (Publisher pub in this.publishersLst.SelectedItems)
{
entityCollection.Attach(pub);
}
但即使它解决了我遇到的第一个问题,我现在又遇到了一个新问题。我似乎找不到解决方案......我什至尝试分离该实体,但没有运气。
我现在得到的错误是:
当此RelatedEnd 的所有者为空时,不允许请求的操作。使用默认构造函数创建的RelatedEnd对象只能在序列化期间用作容器。
有人经历过这个问题吗?
谢谢。
I've been trying to add some selected items from a multi-select listbox on my entry class.
After some research I found that this solution would work:
EntityCollection<Publisher> entityCollection = new EntityCollection<Publisher>();
foreach (Publisher pub in this.publishersLst.SelectedItems)
{
entityCollection.Attach(pub);
}
but even though it solved the first problem I was having I'm getting a new one now. One that I can't seem to find the solution... I even tried detaching the entity, but with no luck.
The error I get now is:
Requested operation is not allowed when the owner of this RelatedEnd is null. RelatedEnd objects that were created with the default constructor should only be used as a container during serialization.
have anyone been through this problem?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我用不同的方式解决了它。
需要一个新的列表才能工作。
问候。
I solved it a different way.
Needed a new List to work.
Regards.