tags:

views:

56

answers:

2

Is it possible to override the SQL generated by LINQ to SQL, for optimisation purposes?

+2  A: 

One way I have used:
Create a stored proc, use the linq to sql designer to drag the proc into the design surface. Call the resulting method instead.

BioBuckyBall
+2  A: 

You could use the ExecuteQuery method instead. This is useful if you want to leverage a function that's available in SqlServer but not in Linq (IE PIVOT, etc...)

For instance:

var query = db.ExecuteQuery<MyType>( @"SELECT ... FROM ... WHERE ...");
Nathan Koop