I just realized if your C# application use LINQ-TO-SQL classes to interface with the database, you can your query like this
using (DatabaseContext context = new DatabaseContext())
{
context.Log = Console.Out;
var query = from Person p in context.People
where person.Name == "john"
select p;
Console.WriteLine(query.Name);
}
What is the equivalent in LINQ-TO-ENTITY (is this another name for ADO.NET?) forcontext.Log = Console.Out
Or there is another way to see your actual SQL query to the database?
I always use SQL Profiler if you have MS SQL Server. What DBMS is this for? LINQ 2 Entities supports multiple DB types.
This also works...
var cust = (from c in context.Customers select c);
string sql = ((ObjectQuery)cust).ToTraceString();
From MSDN forums
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With