I have the following code:
var translations = _context.Translations
Where(t => t.LineId == lines.Id)
I got a variable named lines
which is of type List<Line>
every Line
object has Line.Id
Now I have another table named Translations
I would like to get all Translations which have Line.Id
that is equal to every Line.Id
from the lines
list.
How can I accomplish this in a single LINQ expression?
I need something like this:
var translations = new List<Translation>();
foreach (var line in lines)
{
var translation =
_context.Translations.FirstOrDefault(t => t.LineId == line.Id);
translations.Add(translation);
}