views:

38

answers:

2

I've got a LINQ query that looks like this (at the end):

var query = from myTable0 ... where myTable1.attributeId == 123 && (bunchaStrings.Contains(myTable1.attributeName)) && myTable2.yesNoValue == 'Y'

When I see the query it turns into this

SELECT ... FROM ... INNER JOIN ... WHERE ... AND (UNICODE([t3].[yesNoValue]) = @p3

So what's happening here is that the value of 'Y' is getting turned into '89' via the UNICODE function. That's all fine, but I'd really like to just be able to see the value of @p3 directly and I can't figure out how to see that value via any methods available from my var.

+1  A: 

I would recommend piping the generated SQL out to the output window. There you will be able to see the whole SQL and your parameters values. Then it can also be logged.

Code for it can be found here -> http://www.u2u.info/Blogs/Kris/Lists/Posts/Post.aspx?ID=11

Or an easier method (if you've got a handy console around):

 MyDataContext context = new MyDataContext()
 context.Log = Console.Out
Mike737
brainfart; I totally forgot about .Log on the context. Added it to your answer.
jcollum
+1  A: 

You may also be interested in the LINQ to SQL Visualizer : http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx

Nik