zoukankan      html  css  js  c++  java
  • MVC调试时查看生成的sql语句

    Using the LINQ to SQL Debug Visualizer

    One of the nice development features that LINQ to SQL supports is the ability to use a "debug visualizer" to hover over a LINQ expression while in the VS 2008 debugger and inspect the raw SQL that the ORM will ultimately execute at runtime when evaluating the LINQ query expression.

    For example, assume we write the below LINQ query expression code against a set of data model classes:

    We could then use the VS 2008 debugger to hover over the "products" variable after the query expression has been assigned:

    And if we click the small magnifying glass in the expression above, we can launch the LINQ to SQL debug visualizer to inspect the raw SQL that the ORM will execute based on that LINQ query:

    If you click the "Execute" button, you can even test out the SQL query and see the raw returned results that will be returned from the database:

    This obviously makes it super easy to see precisely what SQL query logic LINQ to SQL ORM is doing for you. 

    You can learn even more about how all this works by reading the Part 3: Querying our Database segment in my LINQ to SQL series above.

    How to Install the LINQ to SQL Debug Visualizer

    The LINQ to SQL Debug Visualizer isn't built-in to VS 2008 - instead it is an add-in that you need to download to use.  You can download a copy of it here.

    The download contains both a binary .dll assembly version of the visualizer (within the \bin\debug directory below), as well as all of the source code for the visualizer:

    To install the LINQ to SQL debug visualizer, follow the below steps:

    1) Shutdown all running versions of Visual Studio 2008

    2) Copy the SqlServerQueryVisualizer.dll assembly from the \bin\debug\ directory in the .zip download above into your local \Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\Visualizers\ directory:

    3) Start up Visual Studio 2008 again.  Now when you use the debugger with LINQ to SQL you should be able to hover over LINQ query expressions and inspect their raw SQL (no extra registration is required).

    Hope this helps,

    Scott

    本文来自:http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx

  • 相关阅读:
    ESLint 配置说明
    ThinkPhp 更改 BIT 类型的问题
    sql server management studio 查询的临时文件路径
    Excel分组快速自动填充编号
    ThinikPhp 将数据库模型的增、删、改操作写入日志
    Window 任务栏清除历史记录
    vscode 中使用php-cs-fixer和PHP Formatter 插件规范化PHP代码
    ThinkPhp 使用PhpExcel导出导入多语言文件
    [UE4]抛物线指示器
    [UE4]瞬移
  • 原文地址:https://www.cnblogs.com/wuzhsh/p/2720997.html
Copyright © 2011-2022 走看看