【问题标题】:LINQ many to many query throws NotSupportedExceptionLINQ 多对多查询抛出 NotSupportedException
【发布时间】:2013-03-19 12:23:29
【问题描述】:

我的 EntityFramework 中有一个多对多的关系。我想查询与特定“mannschaft”相关的所有“teilnehmer”。

这是我的查询

var teilnehmerquery = (from teil in myEntities.Teilnehmer 
                       from man in teil.Mannschaft 
                       where 1==man.MNR 
                       select teil);

如果我运行它,查询会抛出一个NotSupportedException。 怎样做才能让它发挥作用?

【问题讨论】:

  • 如果我尝试 var teilnehmerquery = (来自 teil in myEntities.Teilnehmer from man in teil.Mannschaft where man.MNR==1 select teil);它仍然不起作用

标签: c# linq join entity


【解决方案1】:

试试

var teilnehmerquery = myEntities.Mannschaft.Where( m => m.MNR == 1 )
                                .SelectMany( m => m.Teilnehmer );

【讨论】:

  • 然后我得到“不支持'Select'方法。”
猜你喜欢
  • 1970-01-01
  • 2013-03-25
  • 1970-01-01
  • 1970-01-01
  • 2021-12-09
  • 1970-01-01
  • 1970-01-01
  • 2011-03-23
  • 1970-01-01
相关资源
最近更新 更多