开发者

Override SQL generated by LINQ to SQL?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜