I\'m having great trouble in converting the following SQL to LINQ to SQL, any one able to help out?
SELECT dbo.ExpensesGroup.ExpenseGroupId, dbo.Expenses
linqpad don't convert.
free converter
http://windowsphone.interoperabilitybridges.com/articles/sql-to-linq-converter
Note: Run with SQLite in Windows, not WindowsPhone necesary
To go from LINQ -> SQL try this:
var db = new DBModelDataContext();
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
db.Log = sw; //set the writer
var items = (from rec in db.Table1
select rec).ToList();
var sql = sb.ToString(); //here is the SQL from LINQ.
I tried linqpad but its not for converting SQL to linq but its actual use is to replace sql with linq to query your database
however I think linqer is the right choice if you like to convert SQL query to LINQ. you can download it from their official site.
http://www.sqltolinq.com/
See this existing thread.
If you decide to do it by hand, Linqpad should be useful.