LinqPad-将SQL转换为Linq命令 [英] LinqPad - Convert SQL to Linq command

查看:560
本文介绍了LinqPad-将SQL转换为Linq命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近购买了LINQPad,希望它可以让我将SQL语句转换为LINQ语句.

I recently purchased LINQPad in hopes that it would allow me to convert SQL statements into LINQ statements.

使用LINQPad,我可以附加一个数据库并运行SQL语句,该语句返回所需的结果.

Using LINQPad, I am able to attach a DB and run the SQL statement which returns the results I need.

但是我找不到将该SQL语句转换为LINQ的命令".

But I can not find a 'command' to convert that SQL statement into LINQ.

能否让我知道如何使用LINQPad或其他工具将SQL转换为LINQ?

Can you please let me know how to convert SQL to LINQ by using LINQPad OR another tool?

推荐答案

通常没有像@ andres-abel之前提到的那样将SQL隐蔽到Linq的工具,但是有时您必须编写可以完全按照指定的SQL执行的Linq (例如由于性能问题,向后兼容性或其他一些原因).

In general there are no tools to covert SQL to Linq as @andres-abel mention before, but sometimes you have to write Linq that will execute exactly as specified SQL (for example because of performance issues, backward compatability or some other reasons).

在这种情况下,我会建议您自己进行逆向工程:

  1. 使用以下命令配置由Linq生成的转储SQL语句到stdout的日志记录
  1. configure logging of dump SQL statements generated by Linq to stdout using
    • ObjectQuery.ToTraceString,
    • DbCommand.CommandText,
    • logger availabe to your data source

这篇关于LinqPad-将SQL转换为Linq命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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