208

Is there a tool out there which can convert SQL syntax to LINQ syntax?

I just want to rewrite basic queries with join, etc., to LINQ. It would save me a lot of time.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Chris
  • 6,702
  • 8
  • 44
  • 60
  • There is this tool that uses AI nowadays that converts SQL into C# LINQ. It's [Linq Me Up](https://www.linqmeup.com) – EeKay Feb 24 '23 at 10:20

3 Answers3

85

Edit 7/17/2020: I cannot delete this accepted answer. It used to be good, but now it isn't. Beware really old posts, guys. I'm removing the link.

[Linqer] is a SQL to LINQ converter tool. It helps you to learn LINQ and convert your existing SQL statements.

Not every SQL statement can be converted to LINQ, but Linqer covers many different types of SQL expressions. Linqer supports both .NET languages - C# and Visual Basic.

Nikki9696
  • 6,260
  • 1
  • 28
  • 23
  • 4
    Very buggy. Installer failed for me with "invalid license" message popping up. – Sameer Alibhai Dec 08 '15 at 19:44
  • 2
    Same problem for me. Release notes said they fixed the problem, but not on my network I guess. – Mike Devenney Nov 10 '16 at 20:59
  • 2
    Norton Security Flagged this as bad news! –  Apr 27 '17 at 18:52
  • 1
    AVG reported the 4.6 version as a Trojan!!! Atros3.AKZX. A bug in AVG? – Vojtěch Dohnal Jul 04 '17 at 08:14
  • Looks like it's had no support for 2½ years. I could not even install Linqer correctly. Failed on me with an error: "Not suppported Entity Framework version 0", spelling mistake & all. – user1040323 Sep 28 '18 at 15:00
  • I had to give up on this tool. Apparently I have to generate some kind of model (WHY? I want to convert a very simple 4 line SQL query!) and when I tried to do that it threw an exception because it couldn't find something in Program Files\Windows SDKs. what? – Michael Jul 16 '20 at 23:49
  • this is old now and I cannot delete it. – Nikki9696 Jul 17 '20 at 17:46
  • You have to start it ones with admin rights, and set the path to the SqlMetal.exe, a tool from .Net Framework. It is hard linked to the .NET 4.6 , but any other would also do. – Henry.K Jul 18 '22 at 09:21
36

I know that this isn't what you asked for but LINQPad is a really great tool to teach yourself LINQ (and it's free :o).

When time isn't critical, I have been using it for the last week or so instead or a query window in SQL Server and my LINQ skills are getting better and better.

It's also a nice little code snippet tool. Its only downside is that the free version doesn't have IntelliSense.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
wcm
  • 9,045
  • 7
  • 39
  • 64
29

Bill Horst's - Converting SQL to LINQ is a very good resource for this task (as well as LINQPad).

LINQ Tools has a decent list of tools as well but I do not believe there is anything else out there that can do what Linqer did.


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.

chown
  • 51,908
  • 16
  • 134
  • 170