Shuaib
Shuaib

Reputation: 1579

Subsonic 3 .Save() VS .Update() and .Add()

What is the difference between: .Save();
.Add(); .Update():

Upvotes: 3

Views: 2326

Answers (1)

John Sheehan
John Sheehan

Reputation: 78152

You don't mention which templates you're using (I'm going to assume ActiveRecord), but as a general rule:

  • Save will insert if the object IsNew==true or otherwise it will update.
  • Add will always insert a new record.
  • Update will only update an object with IsNew==false and will fail if there is no corresponding record in the db for the instance.

Upvotes: 10

Related Questions