1

Subsonic 3.0 is updating multiple rows instead of just the one it's supposed to

 DB Table is defined as follows -
 Col1 int NOT NULL
 Col2 Text NOT NULL
 Col3 INT NOT NULL
 ColX NTEXT
 COLY NTEXT

 Primary Key = Col1 + Col2 + Col3
 ....

the select expr is as follows

 myTable a = myTable.SingleOrDefault( x => x.Col1 = 1 && x.Col2 = 'abc' && x.Col3 = 9 );
 if ( a == null )
 {
     // not relevant in this case !
 }

 .... some code 
 a.ColX = myString1;

 a.Update();

@ this point all the rows where Col1 = 1 are set to myString1

env - db is sql 2008 R2 Express, .net 3.5, c#

Cœur
  • 37,241
  • 25
  • 195
  • 267
Kumar
  • 10,997
  • 13
  • 84
  • 134
  • 1
    `x => x.Col1 = 1 && x.Col2 = 'abc' && x.Col3 = 9` is not valid (compilable) C#. Presumably you mean `==`. – Matthew Flaschen Jun 21 '10 at 16:44
  • If your Subsonic query returns >1 record for that primary key, then of course an update on that primary key is going to update every record with that key. The .SingleOrDefault is irrelevant. – Forgotten Semicolon Jun 21 '10 at 16:46

1 Answers1

1

SubSonic does not appear to support composite primary keys - you'll have to create a surrogate key to do what you want.

See also: SubSonic 3 and multiple PK columns

Community
  • 1
  • 1
John Rasch
  • 62,489
  • 19
  • 106
  • 139