1
var possibleTPMs = (from ui in db1.Users
                    from org in db2.Orgs.Where(o => o.OrgId == ui.OrgId && !o.DeletedFlag).DefaultIfEmpty()
                    where !ui.DeletedFlag && ui.ActiveFlag && ui.OrgId == 1 && ui.UserId != 1
                    select new { ui.UserId, ui.LastName, ui.FirstName }).ToList();

Above is sample LINQ but having errors, How can I join these two tables that came from two different databases.

TGnat
  • 3,903
  • 8
  • 35
  • 46
Villapando Cedric
  • 289
  • 1
  • 4
  • 14

1 Answers1

0

To join two 'tables' you simply join them with the below syntax. You shouldn't need any complex join using wheres

var possibleTPMs = (from ui in db1.Users join org in db2.Orgs on ui.id equals org.id select new { ui.UserId, ui.LastName, ui.FirstName }).ToList();

Connor Gervin
  • 935
  • 5
  • 16
  • Hi @Villapando if this or any answer has solved your question please consider [accepting it](http://meta.stackexchange.com/q/5234/179419) by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this. – Connor Gervin Sep 28 '16 at 01:54
  • This doesn't work : 'The specified LINQ expression contains references to queries that are associated with different contexts.' – jug Dec 14 '18 at 13:15