C# 3.0 in a Nutshell
C# 3.0 in a Nutshell, Third Edition A Desktop Quick Reference By Joseph Albahari, Ben Albahari
September 2007
Pages: 858


Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Execution Results While In Debugger
SJ22
post Jul 4 2009, 01:00 PM
Post #1


New Member
*

Group: Members
Posts: 9
Joined: 4-July 09
Member No.: 19,008



I was hoping to use LinqPad to see what the actual state of the db is while stepping through a unit test of NHibernate mappings while in the debugger.

I was hoping I could do things like examining the results of "select * from users" at different points in the test run, but it looks like the connection is hung until the test is finished.

Does it make sense what I'm trying to do? Should I be able to use LinqPad to do it?

Thanks,
Go to the top of the page
 
+Quote Post
JoeAlbahari
post Jul 6 2009, 05:57 AM
Post #2


Advanced Member
******

Group: Members
Posts: 203
Joined: 15-February 08
From: Perth, Australia
Member No.: 90



You can call Dump at any time to see intermediate state. Dump() returns whatever was passed into it, making it convenient to insert within queries.

For instance:

Customers.Dump("all customers")
.Where (c => c.Name.StartsWith ("a')).Dump ("after filtering)
.OrderBy (c => c.Name).Dump ("after ordering")
.Select (c => c.Name)

Does this answer your question?



Go to the top of the page
 
+Quote Post
SJ22
post Jul 6 2009, 09:22 AM
Post #3


New Member
*

Group: Members
Posts: 9
Joined: 4-July 09
Member No.: 19,008



Hi Joseph

What I'm really trying to ask is if I can somehow use query the db state while I'm stepping through a unit test in visual studio that is affecting changes to the db.

When I try to do this LinqPad says it's executing my query but doesn't do anything but wait, presumably because the db connection is being used by the unit test. I've seen SSMS used as a db inspection tool during a unit test and am hoping I can get LinqPad to do the same.

Does my intention seem clear? Is this possible with LinqPad?

Thanks!
Berryl

QUOTE (JoeAlbahari @ Jul 6 2009, 05:57 AM) *
You can call Dump at any time to see intermediate state. Dump() returns whatever was passed into it, making it convenient to insert within queries.

For instance:

Customers.Dump("all customers")
.Where (c => c.Name.StartsWith ("a')).Dump ("after filtering)
.OrderBy (c => c.Name).Dump ("after ordering")
.Select (c => c.Name)

Does this answer your question?


This post has been edited by SJ22: Jul 6 2009, 09:23 AM
Go to the top of the page
 
+Quote Post
JoeAlbahari
post Jul 7 2009, 06:37 AM
Post #4


Advanced Member
******

Group: Members
Posts: 203
Joined: 15-February 08
From: Perth, Australia
Member No.: 90



So are you initiating the unit test from LINQPad - or Visual Studio?
Go to the top of the page
 
+Quote Post
SJ22
post Jul 7 2009, 07:38 AM
Post #5


New Member
*

Group: Members
Posts: 9
Joined: 4-July 09
Member No.: 19,008



QUOTE (JoeAlbahari @ Jul 7 2009, 06:37 AM) *
So are you initiating the unit test from LINQPad - or Visual Studio?


Visual Studio
Go to the top of the page
 
+Quote Post
SJ22
post Jul 8 2009, 05:14 PM
Post #6


New Member
*

Group: Members
Posts: 9
Joined: 4-July 09
Member No.: 19,008



I'm initiating the test from VS.

Thanks!
Go to the top of the page
 
+Quote Post
SJ22
post Jul 12 2009, 06:28 PM
Post #7


New Member
*

Group: Members
Posts: 9
Joined: 4-July 09
Member No.: 19,008



Hi Joe

The answer to your question is that the unit test is initiated in Visual Studio.

Thanks for the prompt reply!


QUOTE (JoeAlbahari @ Jul 7 2009, 06:37 AM) *
So are you initiating the unit test from LINQPad - or Visual Studio?

Go to the top of the page
 
+Quote Post
SJ22
post Jul 14 2009, 03:31 PM
Post #8


New Member
*

Group: Members
Posts: 9
Joined: 4-July 09
Member No.: 19,008



QUOTE (SJ22 @ Jul 12 2009, 06:28 PM) *
Hi Joe

The answer to your question is that the unit test is initiated in Visual Studio.

Thanks for the prompt reply!

Go to the top of the page
 
+Quote Post
JoeAlbahari
post Jul 15 2009, 05:38 AM
Post #9


Advanced Member
******

Group: Members
Posts: 203
Joined: 15-February 08
From: Perth, Australia
Member No.: 90



I'm still not quite sure of the problem.

Is it that when you have several queries in a batch, LINQPad doesn't display the results of queries immediately - but only once they've all completed?

Joe
Go to the top of the page
 
+Quote Post
SJ22
post Jul 16 2009, 12:51 PM
Post #10


New Member
*

Group: Members
Posts: 9
Joined: 4-July 09
Member No.: 19,008



QUOTE (JoeAlbahari @ Jul 15 2009, 05:38 AM) *
I'm still not quite sure of the problem.

Is it that when you have several queries in a batch, LINQPad doesn't display the results of queries immediately - but only once they've all completed?

Joe


Joe:

Here is what I want to happen:

1) start a debug unit session in visual studio using connection db1
2) step over a line that modifies the database in some fashion
3) ** inspect db1 (in LinqPad this could be as simple as "select * from customers")

The problem then:
is that while the unit test is active, LinqPad just hangs; when the unit test is finished then my test fixture will roll any transactions back.

Berryl

This post has been edited by SJ22: Jul 16 2009, 12:52 PM
Go to the top of the page
 
+Quote Post
JoeAlbahari
post Jul 17 2009, 09:57 PM
Post #11


Advanced Member
******

Group: Members
Posts: 203
Joined: 15-February 08
From: Perth, Australia
Member No.: 90



I'm with you now.

The problem is almost certainly that you need LINQPad to use a READ UNCOMMITTED transaction isolation level. This will prevent it from being blocked by active transactions.

A couple of people have asked for this.

Scott Hanselman has also blogged on general topic of setting tx isolation levels in SQL to SQL. Which of his suggested approaches would you prefer?
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 7th November 2009 - 03:20 PM