如何与另一个Join
进行Entity
?
我有这个,
IEnumerable<EntityNetimoveis.San_Imovel> im = db.San_Imovel.Where(a => a.Credenciada_Id.Equals(10));
我希望JOIN
加San_Imovel_Caracteristica
。主键和外键称为Imovel_Id
我试试这个
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));
但这是错误的代码。语法错误。
答案 0 :(得分:2)
基本上,加入是这样的。
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));
编辑:
例如,
var result = db.ATable
.Where(a => a.Name == 'test')
.Join(db.BTable, a => a.Id, b => b.Id, (a, b) => a);
答案 1 :(得分:0)
有一个“。”加入后不应该在那里
答案 2 :(得分:0)
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();