Is there any way of joining two or more tables using Lambda and two different contexts?
Is there any way of joining two or more tables using Lambda and two different contexts?
You can use Linq To Objects
, that is, manipulating data in memory, also recommended < to% C #% to not cache queries. p>
Example
IList<Pessoa> Pessoas = null;
using (Dba1 dba1 = new Dba1())
{
Pessoas = dba1.Pessoa.AsNoTracking().ToList();
}
IList<Telefone> Telefones = null;
using (Dba2 dba2 = new Dba2())
{
Telefones = dba2.Telefone.AsNoTracking().ToList();
}
Pessoas.Join(Telefones, x => x.Id, g => g.PessoaId, (x, g) => new { x, g })
.Select(s => new
{
s.g.Ddd,
s.g.Numero,
s.g.PessoaId,
s.x.Nome
}).ToList();
Note: Not very performative, but in specific cases can be well used, can not become rule of your application .
References: