Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq Update Query generates Where 0 = 1?

I am setting the Address of a class generated by Linq 2 Sql and when I try to SubmitChanges(), the sql query it generates is:

Update Users
Set Address = @po
Where 0 = 1
--@po: Input VarChar (Size = 15; Prec = 0; Scale = 0) [123 45th Street]

I can't figure out why I am getting Where 0 = 1.

like image 831
Xaisoft Avatar asked Feb 16 '10 18:02

Xaisoft


1 Answers

This can happen when your object model differs from the database even by one property.

Is it possible that Address is nullable in the database and not in your model, or the other way around? Or the type differs, say ntext vs nvarchar, etc? In some cases it can be another unrelated property...think back to the last change to the database or model you made, make sure that's in sync.

like image 169
Nick Craver Avatar answered Oct 08 '22 16:10

Nick Craver