Allow conversion of SQL to Linq (where possible)
It would be great if I could paste in an existing SQL query and convert it to LINQ. This capability exists in other tools, but I would prefer to use LINQPad for everything.
In general, LINQ is a higher-level (more abstract) querying language than SQL and this creates some major scope for translation loss in a SQL→LINQ direction. For one, LINQ emits shaped results whereas SQL emits flat result sets. The upshot is that an automatic translation from SQL to LINQ will often have to perform more of a transliteration than translation – and generate examples of how NOT to write LINQ queries. For this reason, I’m loathed to implement such a feature. It would be rather like writing a tool to convert VB6 to C# 4, and then using the output to “learn” C# 4.
To use LINQ properly, you must learn to translate your requirements DIRECTLY into LINQ. If you think first in SQL and then translate to LINQ, you’ll get the worst of both worlds!
LINQ is for people who don't understand SQL...
Ashish Kumar Gupta commented
Is it possible to convert sql statement into Linq statement using LinqPad?
I want to convert this statement using linq pad my quey is
SELECT * FROM TblSourceA FULL OUTER JOIN TblSourceB ON TblSourceA.First=TblSourceB.First OR TblSourceA.Last=TblSourceB.Last;
because how i use or oprator in Linq query
AdminJoe Albahari (Admin, LINQPad) commented
@nurullah - so you're pasting a SQL query into the comment box in the hope that it will magically convert!
select * from CekSenet
left join (select top 1 ceksenet.CariKartFk,ceksenet.CekSenetFk from CekSenet order by CekSenetPK desc ) acs on acs.CekSenetFk = CekSenet.CekSenetPK
where CekSenet.CekSenetFk =0 and acs.CariKartFk = 8
Matthijs de Zwart commented
Linqer does that: http://www.sqltolinq.com/
Jason Short commented
What other tools? I have never seen anything that does that!