CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Insert/Update issue

rated by 0 users
Answered (Not Verified) This post has 0 verified answers | 3 Replies | 1 Follower

Not Ranked
2 Posts
SteveA posted on Tue, Nov 2 2010 2:40 PM

I have a businessbase object that I create with the data portal. I then set the properties equal to input values, then save it, and it runs the insert correctly. Next, I change a property again, then save again. It runs the insert again not the update. Is this how it is supposed to work? How do I make sure that after the object has been saved once it knows that now it should only do updates?

All Replies

Not Ranked
2 Posts

in debugging I noticed that the insert method is correctly loading the ID property, but once it goes back to the page the objects ID property is set to 0. I cannot figure out why the ID is getting lost.

Top 10 Contributor
1,764 Posts
Suggested by dlucid

The Save method actually returns a new object so your code should look like:

rootBO = rootBO.Save();

The returned object is marked as "Old" and next save will be an Update.

Jonny Bekkum, Norway CslaContrib Coordinator

Not Ranked
1 Posts

Also, if you you need the Id parameter from database.

If you are using stored procedure, make output parameter id, you need last inserted id.

 

 

 

Page 1 of 1 (4 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems