how to properly inner join a query? then after i wanna place it to a datagrid
my query statement:
var query = (from ent in ctx.entries
join p in ctx.products on ent.prodId equals p.prodId
join h in ctx.hospitals on ent.hospId equals h.hospId
join c in ctx.contactPersons on ent.contId equals c.contId
where ent.empId == Globals.empId
select ent).ToList();
the error is embedded statement cannot be a declaration or labeled statement
答案 0 :(得分:1)
try something like:
var query = (from ent in ctx.entries
where ent.empId = Globals.empId
&& ctx.Products.Any(a => a.prodId == ent.prodId)
&& ctx.hospitals.Any(a => a.hospId == ent.hospId)
&& ctx.contactPersons.Any(a => a.contId == ent.contId)
select ent).ToList();
edit: Based on the inner joins mentioned in the question.