Good day. There was a problem translating the SQL query into LINQ.

That's the SQL query.

SELECT * FROM Books b JOIN Authors a ON b.RecordID = a.RecordID AND a.TeacherID = 6

It is necessary to translate it into LINQ, but I, unfortunately, could not figure it out. I ask for help

  • 2
    And what is difficult? What did you try to do and what does not work? - Pavel Mayorov
  • one
    Have you tried Linqer sqltolinq.com ? This is SQL-> LINQ converter. LINQPad can also be used linqpad.net - Senior Pomidor
  • one
    You will be helped by the Where() , Join() statements. The algorithm can be for example the following: filter Authors by the condition TeacherId==6 make a connection with Books - Bald

1 answer 1

Honestly I do not know whether it can digest ORM ...

 Books .Join( Authors.Where(x => x.Author.TeacherID == 6), book => book.RecordID, author => author.RecordID, (book, author) => new { Book = book, Author = author } )