Can anybody help me with next: how can I use two different data contexts in one LINQ request?
using (var db = new DataMapDataContext(Connection))
{
using (var dbAdd = new DataMapDataContext(ConnectionAdd))
{
return (from i in dbAdd.ITEMs
join p in db.U_OTT_PINs on i.ITEMNO equals p.PIN_CODE
where p.PIN_TYPE == Utils.PinItem
select ...
}
}
Is it possible?
UPDATE:
I resolved my issue, but not with different data contexts:
var listPinnedItems = new List<string>();
using (var db = new DataMapDataContext(Connection))
{
listPinnedItems = (from lpi in db.U_OTT_PINs
where lpi.PIN_TYPE == Utils.PinItem
select lpi.PIN_CODE).ToList();
}
using (var dbAdd = new DataMapDataContext(ConnectionAdd))
{
return (from i in dbAdd.ITEMs
where listPinnedItems.Contains(i.ITEMNO)
...
I don’t believe so – these two different contexts could be involved in different transactions in the same database, or even talking to completely different database instances. How would it construct SQL to work across the two?
If you could explain what you’re trying to do, we may be able to help you more.