2021年1月18日星期一

Entity Framework Core 5 does not seem to support Where/Include

I read in the EF Core 5 release notes that include/where clauses like this are now supported.

 var results = context.Attendees              .Include(a=>a.SessionPresenters.Where(b=>b.SessionId > 5000))              .Where(c => c.Id == 1124)  

However, when I look at the SQL generated, the 1124 is there but the > 5000 is ignored. What am I not understanding?

Not that it matters, but here is the generated SQL

SELECT `a`.`Company`, `a`.`FacebookId`, `a`.`Id`, `a`.`LinkedInId`, `a`.`PrincipleJob`, `a`.`TwitterHandle`, `a`.`UserBio`, `a`.`UserBioShort`, `a`.`UserFirstName`, `a`.`UserLastName`, `a`.`UserWebsite`, `a0`.`AmazonImageSmall`, `a0`.`Authors`, `a0`.`BookPublishedDate`, `a0`.`BookTitle`, `a0`.`DetailPageUrl`, `a0`.`Id`, `t1`.`c`, `t1`.`AllowHtml`, `t1`.`c0`, `t1`.`c1`, `t1`.`Id`, `t1`.`UrlPostToken`, `t1`.`CodeCampYearId`, `t1`.`Id0`, `t1`.`LectureRoomsId`, `t1`.`MaxAttendance`, `t1`.`c2`, `t1`.`Description`, `t1`.`Id1`, `t1`.`SessionSequence`, `t1`.`SessionsMaterialUrl`, `t1`.`SessionTimesId`, `t1`.`Title`, `t1`.`Id2`, `t1`.`c3`, `t1`.`Id3`, `t1`.`TagName`, `t1`.`Id00`  

FROM Attendees AS a LEFT JOIN AttendeesAmazonBook AS a0 ON a.Id = a0.AttendeesId LEFT JOIN ( SELECT FALSE AS c, s0.AllowHtml, COALESCE(s0.Approved, FALSE) AS c0, FALSE AS c1, c.Id, c.UrlPostToken, s0.CodeCampYearId, s0.Id AS Id0, s0.LectureRoomsId, s0.MaxAttendance, s1.Id IS NULL AS c2, s1.Description, s1.Id AS Id1, s0.SessionSequence, s0.SessionsMaterialUrl, s0.SessionTimesId, s0.Title, s.Id AS Id2, t0.c AS c3, t0.Id AS Id3, t0.TagName, t0.Id0 AS Id00, s.AttendeeId FROM SessionPresenter AS s INNER JOIN Sessions AS s0 ON s.SessionId = s0.Id INNER JOIN CodeCampYear AS c ON s0.CodeCampYearId = c.Id LEFT JOIN SessionLevels AS s1 ON s0.SessionLevel_id = s1.Id LEFT JOIN ( SELECT FALSE AS c, t.Id, t.TagName, s2.Id AS Id0, s2.SessionId FROM SessionTags AS s2 INNER JOIN Tags AS t ON s2.TagId = t.Id ) AS t0 ON s0.Id = t0.SessionId ) AS t1 ON a.Id = t1.AttendeeId WHERE a.Id = 1124 ORDER BY a.Id, a0.Id, t1.Id2, t1.Id0, t1.Id, t1.Id1, t1.Id00, t1.Id3

https://stackoverflow.com/questions/65784957/entity-framework-core-5-does-not-seem-to-support-where-include January 19, 2021 at 11:04AM

没有评论:

发表评论