无法使用探查器时看到LINQ to SQL文本 [英] Seeing LINQ to SQL text when you can't use the profiler

查看:68
本文介绍了无法使用探查器时看到LINQ to SQL文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows应用程序,该应用程序使用LINQ to SQL并具有已锁定的数据库(因此我无法在其上使用SQL Server Profiler).

我想查看应用程序正在发送的实际SQL文本;查看仅使用Windows应用程序(而不是数据库)发送的SQL文本的最简单方法是什么?

I have a Windows application using LINQ to SQL with a database that''s locked down (so that I can''t use SQL Server Profiler on it).

I''d like to see the actual SQL text that the application is sending; what''s the easiest way to see the SQL text sent using just the Windows application (and not the database)?

推荐答案

尝试如下代码:
Try as below code:
TestDataContext testDataContext = new TestDataContext();

IQueryable<employee> myQuery =
  from emp in testDataContext.Employee
  where emp.EmployeeId == 123
  select emp;

string sqlCommand = testDataContext.GetCommand(myQuery).CommandText;</employee>


这篇关于无法使用探查器时看到LINQ to SQL文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆