2025-05-11 05:00:00

SQL to LINQ工具

是否有一个工具可以将SQL语法转换为LINQ语法?

我只是想用join等重写基本的查询到LINQ。这会节省我很多时间。


编辑7/17/2020:我无法删除这个已接受的答案。以前很好,但现在不行了。伙计们,小心那些老帖子。我正在删除链接。

[Linqer]是一个SQL到LINQ转换工具。它可以帮助您学习LINQ并转换现有的SQL语句。

不是每个SQL语句都可以转换为LINQ,但是Linqer涵盖了许多不同类型的SQL表达式。Linqer同时支持。net语言——c#和Visual Basic。


我知道这不是你想要的,但LINQPad是一个非常好的工具,可以自学LINQ(而且它是免费的:o)。

当时间不是很关键的时候,我已经在过去的一周左右使用它或SQL Server中的查询窗口,我的LINQ技能越来越好。

它也是一个不错的小代码片段工具。它唯一的缺点是免费版没有智能感知功能。


Bill Horst的《将SQL转换为LINQ》是一个非常好的资源(以及LINQPad)。

LINQ Tools也有一个不错的工具列表,但我不相信还有其他工具可以做到Linqer所做的。


Generally speaking, LINQ is a higher-level querying language than SQL which can cause translation loss when trying to convert SQL to LINQ. For one, LINQ emits shaped results and SQL flat result sets. The issue here is that an automatic translation from SQL to LINQ will often have to perform more transliteration than translation - generating examples of how NOT to write LINQ queries. For this reason, there are few (if any) tools that will be able to reliably convert SQL to LINQ. Analogous to learning C# 4 by first converting VB6 to C# 4 and then studying the resulting conversion.