I\'ve recently upgraded to VS 2010 and am playing around with LINQ to Dataset. I have a strong typed dataset for Authorization that is in HttpCache of an ASP.NET WebApplicat
Your first approach (SQL query in the DB) is quite efficient because the DB knows how to perform a join. But it doesn't really make sense to compare it with the other approaches, since they work directly in memory (Linq to DataSet)
The query with multiple tables and a Where
condition actually performs a cartesian product of all the tables, then filters the rows that satisfy the condition. This means the Where
condition is evaluated for each combination of rows (n1 * n2 * n3 * n4)
The Join
operator takes the rows from the first tables, then takes only the rows with a matching key from the second table, then only the rows with a matching key from the third table, and so on. This is much more efficient, because it doesn't need to perform as many operations