0

嗨,大家好,也许我写这个错误的方式,但不能使它工作。第三级过滤器

我得到了下面的实体模型: [师] < 0..1> - < *> [会议] < 1> - < 0..1> [电影]

我运行以下LINQ查询(在LINQPad):

from d in Divisions select new {d, d.Sessions, 
films = from s in d.Sessions where s.Film.Title !=null select s} 

,但我得到的错误:

Constructing or initializing instances of the type <>f__AnonymousType0 3[LINQPad.User.Division,System.Collections.ObjectModel.Collection 1[LINQPad.User.Session],System.Collections.Generic.IEnumerable`1[LINQPad.User.Session]] with the expression d.Sessions.Where(s => (s.Film.Title != null)) is not supported.

我不知道是否有在AP上的限制在WCF数据服务的第三级使用过滤器,或者这是我的错误观念。

+0

http://stackoverflow.com/questions/14532184/wcf-data-services-query-projection-with-nullable-navigation-properties可能会有帮助。 – Narthring

+0

@Narthring。谢谢你的作品! – objecto

回答

0

看来这家伙here是通过使用正确的 ? (IIF)运营商这样的 “标题=(s.Film == NULL)空:s.Film.Title” 工作正常。因此,即使Film对象为空,以下表达式也可以正常工作

var _divsess = from d in Divisions select new 
    {d , sessionsfilms = from s in d.Sessions 
    select new {s, title= (s.Film == null) ? null : s.Film.Title }};