Wriju's BLOG

.NET, Cloud and everything

LINQ to SQL : New method DataContext.GetCommand()

LINQ to SQL we can read the generated T_SQL query using DataContext.Log or SQLQueryVisualizer. But If you are working with WebProject the Log property not very much convenient as you have to use TextWriter to dump the generated T-SQL query.


 


In Orcas Beta 1 we had DataContext.GetQueryText which used to give us the generated T-SQL now we do not have this from Visual Studio 2008 Beta 2. I have mentioned about this change in one of my earlier Blog post. The implementation is here,


 


TextBox1.Text = db.GetCommand(query).CommandText;


 


Now this will give you the DataContext generated T-SQL query.


 


Namoskar!!!