开发者

Execute LINQ generated SQL in SSMS

开发者 https://www.devze.com 2023-01-25 11:03 出处:网络
I use the LINQ DataContext\'s 开发者_JS百科Log property to send the generatated SQL to the debug window. (There is a post by Kris Vandermotten about that). That works fine, except that the ouputted SQ

I use the LINQ DataContext's 开发者_JS百科Log property to send the generatated SQL to the debug window. (There is a post by Kris Vandermotten about that). That works fine, except that the ouputted SQL parameters are some SQL comments, and so I can't run the query in Management Studio. Here's an example:

SELECT * FROM table WHERE id IN (@p0,@p1,@p2)
-- @p0: Input Int (Size = 0; Prec = 0; Scale = 0) [5]
-- @p1: Input Int (Size = 0; Prec = 0; Scale = 0) [1]
-- @p2: Input Int (Size = 0; Prec = 0; Scale = 0) [13189086]

So, is there any tool that transforms this text into a valid SQL?


You can grab LINQPad (free!) and run your LINQ to SQL directly. Then click on the "SQL" tab in LINQPad to see the generated SQL. It will DECLARE all the parameters for you and you could copy/paste that into SSMS (or click "Analyze SQL" from the SQL tab to launch it in SSMS). You can also run it directly from LINQPad.

Screenshot:

Execute LINQ generated SQL in SSMS

0

精彩评论

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

关注公众号