0

我怎么能Join和另一个做一个Entity

我有这个,

IEnumerable<EntityNetimoveis.San_Imovel> im = db.San_Imovel.Where(a => a.Credenciada_Id.Equals(10));

我想要一个JOINwith 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));

但这是一个错误的代码。有语法错误。

4

3 回答 3

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);
于 2012-08-24T18:20:01.843 回答
0

有个 ”。” 加入后不应该在那里

于 2012-08-24T18:16:33.517 回答
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();
于 2012-08-24T18:18:59.677 回答