Adding to collection but not to database

Adding to collection but not to database

Old forum URL: forums.lhotka.net/forums/t/3987.aspx


OneBadApple posted on Wednesday, December 05, 2007

With CSLA is it possible to add to the collection, without inserting the row into the database first?

Thanks,
Lauren

Michael Hildner replied on Wednesday, December 05, 2007

Yes. For example if your class derives from BusinessListBase, you can call .Add or .AddNew. The new item is in memory until you call .Save to persist to the DB.

Regards,

Mike

OneBadApple replied on Thursday, December 06, 2007

Can this be done when the class derives from BusinessCollectionBase?  Are there any examples that you know of that I can look it?  Using the BusinessCollectionBase, all examples that I have seen have the .Add method call a .New method from the child class that does the actual insert into the database.

Thanks for the reply, Mike.

Lauren

Michael Hildner replied on Thursday, December 06, 2007

I may be missing something, but I believe that BusinessCollectionBase is from the 1.x days. I started using CSLA with 2.something. Sorry, maybe someone else knows.

Regards,

Mike

ajj3085 replied on Friday, December 07, 2007

I thought it was BusinessListBase?  Anyway, that's the default behavior, so you don't need to do anything special.  What examples are you looking at, because AFAIK they all show the standard method, which is new in memory until save is called on the collection.

Michael Hildner replied on Friday, December 07, 2007

I looked at the change log for 2.0, changes from 1.x, and BusinessCollectionBase was replaced with BusinessListBase. I don't know how 1.x worked as I never used it.

ajj3085 replied on Friday, December 07, 2007

Ok, well the concept is the same, and either way nothing should be saving to the database until you call save.  Check out the example that came with whatever version of Csla you downloaded.

Copyright (c) Marimer LLC