locked
Joining Tables across Databases RRS feed

  • Question

  •  

    Hi

     

    I have to join almost five to six tables across databases. So I have created a different context and written join qery it is throwing exception. How to do it using LINQ?

     

    Thanks

    Anandraj.A.

    Monday, June 16, 2008 11:03 AM

Answers

  • Another option is just to create the query as a view in your database and then access that via LINQ to SQL.

     

    [)amien

     

    Monday, June 16, 2008 10:19 PM

All replies

  • You will need to cast the results of each table fetch ToList and then use LINQ to Objects to perform the heterogeneous join. If you know that the result of particular queries are rather small, you may be able to use the Where list.Contains(item.value) syntax to perform an Where value IN (list) SQL statement. Be aware that heterogeneous queries require that you take a fair amount of care to avoid fetching the least number of rows across the network.

     

    Jim Wooley

    www.ThinqLinq.com

    Monday, June 16, 2008 5:06 PM
  • Another option is just to create the query as a view in your database and then access that via LINQ to SQL.

     

    [)amien

     

    Monday, June 16, 2008 10:19 PM