Is it possible to extract sql statements from LINQ queries ?
Say, I have this LINQ expression.
string[] names =
new string[] { "Jon Skeet", "Marc Gravell", "tvanfosson",
"cletus", "Greg Hewgill", "JaredPar" };
var results = from name in names
where name.StartsWith("J")
select name;
After this statement 'results' is only holding the LINQ expression and not the results due to deferred execution of LINQ queries.
Can I extract or produce the LINQ query out of 'results' and prepare a valid SQL statement from the query stored in 'LINQ'?
EDIT
Here's My objective:
We have written our own ORM. We have to write queries every-time we need to do db operations. Now we need to get rid of it at DAL. We wish to write LINQ expression in code which will produce SQL statements against my ORM and we will execute this SQL on the database.
Will I haev to write my custom Linq Providers to do what I need ?