title: Having trouble doing an Update with a Linq to Sql object
body: <p>i've got a simple linq to sql object. I grab it from the database and change a field then save.</p>
  
  <p>No rows have been updated. :(</p>
  
  <p>When I check the full Sql code that is sent over the wire, I notice that it does an update to the row, not via the primary key but on <em>all</em> the fields via the where clause. Is this normal? I would have thought that it would be easy to update the field(s) with the where clause linking on the Primary Key, instead of where'ing (is that a word :P) on each field.</p>
  
  <p>here's the code...</p>
  
  <pre><code>using (MyDatabase db = new MyDatabase())
  {
      var boardPost = (from bp in db.BoardPosts
          where bp.BoardPostId == boardPostId
          select bp).SingleOrDefault();
  
      if (boardPost != null &amp;&amp;
          boardPost.BoardPostId &gt; 0)
      {
          boardPost.ListId = listId; // This changes the value from 0 to 'x'
          db.SubmitChanges();
      }
  }
  </code></pre>
  
  <p>and here's some sample sql..</p>
  
  <pre><code>exec sp_executesql N'UPDATE [dbo].[BoardPost]
  SET [ListId] = @p6
  WHERE ([BoardPostId] = @p0) AND .... &lt;snip the other fields&gt;',N'@p0 int,@p1 int,@p2 nvarchar(9),@p3 nvarchar(10),@p4 int,@p5 datetime,@p6 int',@p0=1276,@p1=212787,@p2=N'ttreterte',@p3=N'ttreterte3',@p4=1,@p5='2009-09-25 12:32:12.7200000',@p6=72
  </code></pre>
  
  <p>Now, i know there's a datetime field in this update .. and when i checked the DB it's value was/is '2009-09-25 12:32:12.720' (less zero's, than above) .. so i'm not sure if that is messing up the where clause condition...</p>
  
  <p>but still! should it do a where clause on the PK's .. if anything .. for speed!</p>
  
  <p>Yes / no ?</p>
  
  <hr>
  
  <p>UPDATE</p>
  
  <p>After reading nitzmahone's reply, I then tried playing around with the optimistic concurrency on some values, and it still didn't work :(</p>
  
  <p>So then I started some new stuff ... with the optimistic concurrency happening, it includes a where clause on the field it's trying to update. When that happens, it doesn't work.</p>
  
  <p>so.. in the above sql, the where clause looks like this ...</p>
  
  <pre><code>WHERE ([BoardPostId] = @p0) AND ([ListId] IS NULL) AND ... &lt;rest snipped&gt;)
  </code></pre>
  
  <p>This doesn't sound right! the value in the DB is null, before i do the update. but when i add the ListId value to the where clause (or more to the point, when L2S add's it because of the optomistic concurrecy), it fails to find/match the row.</p>
  
  <p>wtf?</p>