开发者

Override SQL generated by LINQ to SQL?

开发者 https://www.devze.com 2022-12-19 10:53 出处:网络
Is it possible to override the SQL generat开发者_如何学Goed by LINQ to SQL, for optimisation purposes?You could use the ExecuteQuery method instead. This is useful if you want to leverage a function t

Is it possible to override the SQL generat开发者_如何学Goed by LINQ to SQL, for optimisation purposes?


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 ...");


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号