0

I wrote an application which is working with strongly typed datasets and adapters.

First it reads data from database and store it to the typed datatable.Second this datatable processed by this application (add, delete or update rows) and last writes updated data back to the database.

On the step of updating sometimes application causes the exception of

Violation of PRIMARY KEY constraint 'PK_GPS_Events_History'. Cannot insert duplicate key in object 'dbo.GPS_Events_History'. The duplicate key value is (16805552).

The statement has been terminated."} System.Exception {System.Data.SqlClient.SqlException}

Table GPS_Events_History at the moment of exception contains about ~30000 rows. How to filter data in datatable to look at this single row with ID=16805552? I tried to filter it by following code:

dataTable.where(row => row.ID == 16805552)

but VS2010 didn't allow me to enter any LINQ expression in debugger variables window.

Community
  • 1
  • 1
Anton Agapov
  • 143
  • 1
  • 9

2 Answers2

1

Make the result you want to debug save to a variable, then inspect the variable:

var testData = dataTable.Where(row => row.ID == 16805552);
//once the line above has executed, quickwatch the "testData" variable

You can't put lambdas in a quickwatch window, so this is the next best thing.

Community
  • 1
  • 1
gunr2171
  • 16,104
  • 25
  • 61
  • 88
  • The problem is that bug is floating and ID is every time changed. And as I understand I couldn't change the code in execution time to see this current value – Anton Agapov Nov 07 '14 at 16:41
  • 1
    If you're debugging, you should know what the value is when you breakpoint to it. If not, then replace the hardcoded number with some variable that contains the ID you are looking for. – gunr2171 Nov 07 '14 at 16:45
0

I typed following command in quick watch window and it solved the problem:

Select("ID = 16805552")
Anton Agapov
  • 143
  • 1
  • 9