How do I write this cross apply query in LINQ-to-SQL?

This should do the trick

var query = from a in context.TableA
            from b in context.TableB
                             .Where(x => x.TableA_Id == a.Id)
                             .OrderBy(x => x.Value)
                             .Take(10)
            where a.Key >= 0 && a.Key <= 999
            select new
            {
              a.Key,
              b.Value,
            };

Leave a Comment