Where clause on collection

后端 未结 3 1474
孤街浪徒
孤街浪徒 2020-12-10 18:43

I\'m using the BAGA code from Julie Lerman\'s DbContext book. I want to recreate the following SQL query in LINQ and put the results in a List collections and am having pro

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-10 19:29

    Normally this is done using navigation properties which are loaded when you get the entity.

    However you can also do this with the following:

    (from d in baga.Locations
     from l in Lodgings
     where (d.LocationID == l.destination_id)
     where (d.Country = 'usa' && (l.MilesFromNearestAirport > 5 || l.MilesFromNearestAirport == null))
     select d)
     .ToList();
    

    I hope this will help to you.

提交回复
热议问题