Where clause on collection

后端 未结 3 1496
孤街浪徒
孤街浪徒 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:28

    How about using the LINQ join?

     var res = from d in context.Destinations
               join l in context.Lodgings on d.LocationID equals l.destination_id
               where (l.MilesFromNearestAirport > 5 || l.MilesFromNearestAirport == null)
                     && d.Country = "usa"
               select new {
                         Destination = d,
                         Location = l
                      }
    

提交回复
热议问题