sexta-feira, 13 de julho de 2012

How to execute a Join using LINQ to SQL, using option Keys in JOIN



If you want to retrieve data using the join clause in SQL Queries maybe you need to execute the query bellow:


                var result = ((from sample1 in context.table1
                               join sample2  in context.table2  on true equals true /* hack join */
                              where  (sample1.key1 == sample2.key2 || sample1.key1 == sample2.key2)
                               select sample1)).AsQueryable();

                return result.ToList();


Use true equals true to hack the join and filter using the where criteria.



Postar um comentário