请教:未处理InvalidOperationException,无法返回此 EntityCollection 或 EntityReference 的源查询。

jobcty00 2014-08-18 11:23:29
private void suppliersList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
this.supplier = listBox1.SelectedItem as Supplier;
this.northwindContext.LoadProperty<Supplier>(this.supplier, s => s.Products);
this.productsInfo = ((IListSource)supplier.Products).GetList();
productsList.DataContext = this.productsInfo;
}
===上面是源代码===
错误出现在当supplier表添加新记录并选择该记录时,
this.northwindContext.LoadProperty<Supplier>(this.supplier, s => s.Products);该行代码出错,
提示“未处理InvalidOperationException:当相关对象处于 added 状态或 detached 状态时,并且最初并非使用 NoTracking 合并选项进行检索时,无法返回此 EntityCollection 或 EntityReference 的源查询。”
...全文
60 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧