Suppose that I have this two tables:
- TableA(IDTableA, ...)
- TableB(IDTableB, IDTableA, ...)
I would like a subquery with LinQ like this:
select *
from MytableA
where IDTableA = (select IDTable A From TableB where IDTableB = 123);
I am trying something like this:
MytableA myTableAEntity = dbContext.MytableA
.Where(x=>x.IDTableA == dbContext.MytableB.Where(y=>y.IDTableB == 123).SingleOrDefault();
But I have an error that says that I can't cast IQueryable<long>
into a long.
Is it possible to do something like that?
Thank so much.