score:3

Accepted answer

Try:

 public Func<DataContext, int, IQueryable<Item>> Query1 = 
    CompiledQuery.Compile((DataContext context, int id) =>
      (from table1 in context.GetTable<Table1>()
      where table1.foreignId = id
      select new Item(table1))
    .Union(
      (from table2 in context.GetTable<Table2>()
      where table2.foreignId = id
      select new Item(table2))
    ));

Related Articles