Entity Framework subquery

后端 未结 2 1930
一整个雨季
一整个雨季 2020-12-31 12:35

Guys I am new to Entity Framework and I\'m having a bt of a problem that I have been trying to solve for quite a while. Basically I have 4 entities: users, groups, books an

2条回答
  •  [愿得一人]
    2020-12-31 13:11

    Personally I think there is a better solution(untested of course):

    First select from ReadList by GroupdID, then join in books on BookID.

    IQueryable q = 
           from rl in entities.ReadingList
           join b in entities.Books on rl.BookID equals b.BookID
           where rl.GroupdID ==groupID
           select b;
    
    var books = q.ToList()
    

    Please let me know if you have any issues.

提交回复
热议问题