2

I have a DataTable, and need to extract the data by using this SQL query:

SELECT code_direction, count(TP) AS CN FROM table1 WHERE 
                  cod_time = 'A011' GROUP BY TP,code_direction;

Which is the C# LINQ equivalent query? After it I want to move the results into a new DataTable.

I tried many examples founded around in web but no this specific logic.

gideon
  • 19,329
  • 11
  • 72
  • 113
Alessandro
  • 55
  • 1
  • 7

1 Answers1

1

Linqer is your friend!

This tool can translate SQL to LINQ. You can download it at http://www.sqltolinq.com.

Note that it's not always possible to convert a SQL query straight into a 100% equivalent LINQ query, but it should be close enough.

If you need translation in the other direction -- from LINQ to SQL -- you can use LINQPad. Download it at http://www.linqpad.net/.

Roy Dictus
  • 32,551
  • 8
  • 60
  • 76
  • Has Linqer resolved their virus warnings? http://stackoverflow.com/questions/296972/sql-to-linq-tool – Robert Harvey Dec 12 '11 at 16:46
  • It appears they have. Just downloaded it and ran it and NAV Corporate installed on my machine didn't complain. He's apparently been fighting this for a while. Seems that it was due to a compression tool he was using? http://sqltolinq.proboards.com/index.cgi?board=general&action=display&thread=58 – Tim Coker Dec 13 '11 at 14:25