What is the difference between:
.Save();
.Add();
.Update():
views:
744answers:
1
+9
A:
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.
John Sheehan
2009-07-14 18:44:45
Thanks John. Yes, I am using Active Records.BTW, I read a bit of your "How I Use SubSonic" article but noticed it 's for Subsonic 2. Now, this is my first time using Subonic (v 3) and looking for some advise on how to layer my application (DAL, BLL, UI). I for sure don't want to expose the DAL to my UI. Any tips?
Shuaib
2009-07-14 20:03:25
Don't use ActiveRecord ;) I would start by familiarizing yourself with the LinqTemplates. It makes it a lot easier to separate your layers. That's a good idea for another blog post though...bringing the 2.x stuff up to speed on 3.
John Sheehan
2009-07-14 20:10:38
Thanks John.I will read about LinqTempaltes. I think it is time for a new blog post.
Shuaib
2009-07-14 20:27:30
What's the difference between ActiveRecord and LinqTemplates?
Jon
2009-07-15 08:24:12
The LinqTemplates use the Repository pattern which makes it easier to keep all your data access code in one place (far from the UI)
John Sheehan
2009-07-15 14:23:14
John,any example of how LinqTempaltes would make things easier?
Shuaib
2009-07-16 14:34:37