【发布时间】:2011-05-09 11:54:58
【问题描述】:
我在 EF4 中有一个带有抽象基类的 TPT 场景。
我需要对一组子类型进行 linq 查询,以从一种父类型的字段中获取值。
例如。
ThisChild = Children.Where(c. => c.Parent.OfType<Mother>.JewelleryCollection > 10).FirstOrDefault();
在这种情况下,Parent 是抽象类,而 Mother 是 Parent 的一种。 Mother 是唯一具有 JewelleryCollection 字段的类型。
上面的例子中断了,因为你不能使用 .OfType 方法。我怎样才能最好地构造这个查询?
谢谢。
【问题讨论】:
-
ObservableCollection
Children = new ObservableCollection ();
标签: c# linq entity-framework-4 parent table-per-type