title: Is there a tool to convert T-SQL Stored Procedures to C#?
body: <p><strong>Update from 2017:</strong></p>
  
  <p>Realistically, the answer is <strong>no, and even if there were you should be extremely cautious of using it</strong>.</p>
  
  <p>There are really only two ways to attack this problem:</p>
  
  <p>a) Bite the bullet and convert everything manually and painstakingly and with some method of verification to check that everything continues to behave as intended, like unit/regression tests. Use tools like Linqer, if available, as <em>assistance</em>, to solve a part of the problem.</p>
  
  <p>b) Start over from scratch.</p>
  
  <p>There is no option c) to have something else handle everything neatly and automatically, and it could not possibly cover all cases. There are many things T-SQL can do that LINQ can't (updates, inserts and deletes spring to mind), and many things that you would be better off doing a different way in C# (like cursors).</p>
  
  <p>Very few problems like this get well-engineered, exhaustive solutions that can be trusted not to regress functionality (like commercial VB6 to VB.NET converters that could justify spending enormous effort because of the sheer volume of potential customers out there, and where you can pick up a phone or a lawyer if something goes wrong), so if such a tool existed you should be extremely careful. The translation from the LINQ-compatible subset of SQL to LINQ is a bounded problem that is well-understood by the  and I think Linqer can be trusted.</p>
  
  <p>This question was trying to suss out a tool that could assist with option a) but I imagine many people reading this are looking for option c). There is a subset of this question and answer that is not a horrible idea, but it does not automate away the remaining burden, since even many of the simple stored procedures did more than querying in a LINQ-expressible form. It was still far too untenable to do option a) for any of the projects I mentioned.</p>
  
  <hr>
  
  <p>Original question follows:</p>
  
  <p>I have a few projects to maintain that use a lot of SQL Server stored procedures (in T-SQL). I know how to maintain them, but since there are many tools to automatically convert between different languages, I'm wondering if there's any tool to convert the stored procedures to C# code?</p>
  
  <p>I do NOT want to convert them to CLR Stored Procedures; I simply want to migrate the logic in my data layer to the C# end of my project and automate the grunt work. Most of the stored procedures (maybe 70%?) are simple "SELECT * FROM table WHERE id = @id" affairs, and they could be done just as well with Entity Framework.</p>
  
  <p>I know that it's not a straight line between T-SQL and C# as it is from VB.NET to C# and that conversion isn't as straightforward; you will need to introduce a data layer in C#, for example, and some things like cursors don't have corresponding concepts. I just want to move off of stored procedures without the repetitive manual labor if possible.</p>
  
  <p>Since this has been put into question by faulty assumptions: I already know T-SQL, and given the code of any one of these stored procedures I could tell you what they do. There are very good practical reasons why I do not want the logic to continue residing in stored procedures. </p>