Reputation: 4740
How can I do a Join
with another Entity
?
I have this one,
IEnumerable<EntityNetimoveis.San_Imovel> im = db.San_Imovel.Where(a => a.Credenciada_Id.Equals(10));
I want a JOIN
with San_Imovel_Caracteristica
. Primary Key and Foreign Key called Imovel_Id
I try this one
IEnumerable<EntityNetimoveis.San_Imovel> im = db.San_Imovel.Join.(IEnumerable<EntityNetimoveis.San_Imovel_Caracteristica>, i => imovel_id, a => imovel_Id).Where(a => a.Credenciada_Id.Equals(10));
but this is a wrong code. Has syntax error.
Upvotes: 0
Views: 3419
Reputation: 18387
var query = from EntityNetimoveis.San_Imovel i in db.San_Imovel
join EntityNetimoveis.San_Imovel_Caracteristica c in db.San_Imovel_Caracteristica on i.imovel_id equals c.imovel_Id
select i;
return query.ToList();
Upvotes: 0
Reputation: 62260
Basically, joining is like this.
var im =
db.San_Imovel.Join(db.San_Imovel_Caracteristica, i => i.imovel_id, a => a.imovel_Id, (i, a) => a)
.Where(a => a.Credenciada_Id.Equals(10));
Edited:
For example,
var result = db.ATable
.Where(a => a.Name == 'test')
.Join(db.BTable, a => a.Id, b => b.Id, (a, b) => a);
Upvotes: 2