How to log SQL when using LINQ to SQLs DataContext
‘Dim LINQ log variables
Private sbLog As New StringBuilder Private swLog As New StringWriter(sbLog)
‘Execute of LINQ ** dcNwind is the instantiation of the DataContext **
dcNwind.Log = swLog
‘To Display log
sbLog.ToString
How to log SQL when using LINQ to SQL with Entities
** allArticles being the query object of the entity **
Dim mSQL As String = CType(allArticles, Objects.ObjectQuery).ToTraceString()