title: Linq Update Problem
body: <p>I'm having some problems updating the database using Linq...</p>
  
  <pre><code> Public Shared Function Save(ByRef appointment As MyLinq.Appointment, ByRef db As MyEntities) As Boolean
  
          If appointment.id = 0 Then
              db.AddToAppointments(appointment)
          Else
              db.AttachTo("Appointments", appointment)
              'db.ApplyPropertyChanges("Appointments", appointment)
          End If
  
          Return db.SaveChanges() &gt; 0
  
      End Function
  </code></pre>
  
  <p>So Insert works fine, i have tryed both lines of code for the update with no sucesss... The first one goes ok but no update is performed, the second one throws an exception...</p>
  
  <p>Can someone point out what i am missing?</p>
  
  <p>EDIT:</p>
  
  <p>Sorry for the late reply... I had some internet connection problems...</p>
  
  <p>I had to "make it work", so now my update code is fecthing the record from the database, updating and then executing "SaveChanges" method. It works but I am not happy having to query the database to perform an Update... If you have any idea how I could do this without an update I would appreciate :)</p>
  
  <p>Chris: It was a nice try, but my refresh method only allows me to choose "RefreshMode.ClientWins" or "RefreshMode.StoreWins" I tried with ClientWins with no success...</p>
  
  <p>Razzie: I am sorry but i did not save the exception and it no longer occurs... It was saying that my record did not have a key associated (or something similar)</p>
  
  <p>Jon Skeet: In Vb.Net we have to specify if the parameter goes ByVal or ByRef, we can't omit like in C#</p>