Reputation: 45
I need do in c# this sql query
select a.Codigo,c.Capacidad,c.Dia,c.jefe
from Autonomo a, Centro c
where a.Codigo_Centro=c.Codigo and a.Codigo_PC=1022;
How can I do it with LINQ to sql? Thanks!
Upvotes: 0
Views: 249
Reputation: 3682
just FYI other answer is missing where clause.don't forget where clause
var query = from a in Autonomo
join c in Centro
on a.Codigo_Centro equals c.Codigo
where a.Codigo_PC == 1022
select new { a.Codigo,c.Capacidad,c.Dia,c.jefe};
Upvotes: 1
Reputation: 21
Try:
var resultado =
from a in Autonomo
join c in Centro on a.Codigo_Centro equals c.Codigo
select new { a.Codigo,c.Capacidad,c.Dia,c.jefe};
To print:
foreach (var item in resultado)
{
Console.WriteLine(item.Codigo + ", " + item.Capacidad);
}
Upvotes: 2