You are probably encountering one of the highlighted breaking changes from version 3.5 - the AutoCloneOnUpdate behavior.
You can search for that word and find it discussed over the past 2-3 years.
In CSLA 3.0 AutoCloneOnUpdate was added, with a default of false - which preserved backward compatibility.
A year or so later, in version 3.5, the default was changed to true - which breaks backward compatibility unless you add a config file entry to make it false.
The idea of AutoCloneOnUpdate is to ensure the local data portal provides (nearly) the same semantic behavior as the remote data portal, so the Save() method returns a new instance of the object if the operation succeeds.
This was done to avoid two of the biggest issues people were facing 2-3 years ago. The first is that it wasn't transparent to switch between local and remote data portal code, because it was possible to write (technically incorrect) client code that ignored the result of Save(). The second is that correct UI code not only used the result of Save(), but had a bunch of exception handling to deal with the case where the database update failed in the middle.
Since most people didn't write correct data portal code when using a local data portal, I phased in AutoCloneOnUpdate over a 2 year period to "encourage" people to write correct UI code - and to simplify what was meant by "correct UI code".
You have two choices - either add an entry in your config file to set AutoCloneOnUpdate to false, or fix your UI code so it is correct.
Obviously if your current code is working for you, you may not see this as a "fix", which is why the switch exists to get the older behavior :)
FYI - the config file entry needs to be a very short term solution. i.e. use it only to compile the app while you hunt down the real issue.
And it is a simple issue. In fact it is the #1 bug in the code of users of CSLA.
You must have written code like this:
myBO.Save()
That is a bug in your code! If you ever switch the dataportal to a remote scenario your code will be broken! That is why Rocky added the autocloneonupdate feature.
Your code simply needs to be changed to this:
myBO = myBO.Save()
===================================================================
On a similar note I ran into an IsDirty issue recently - I have converted a large web app from CSLA 2.1 to 3.6 and noticed that some classes didn't work right. The reason is that the DataPortal calls MarkNew and then Create. It also calls MarkOld and then Fetch.
My classes "normally" call one of the Mark methods at the end of Create or Fetch and then called check rules. But for some hand coded classes I relied on the older behavior where the dataportal did not call them for you. So in a Fetch when I omitted MarkOld, the BO acted as if I had called MarkNew and it was then used in my app that way. After the upgrade - it broke because now the framework called MarkOld.
I had two ways to fix it - one was to call MarkNew at the end of a fetch - which would be silly. The other was to move the code to DataPortal_Create instead of Fetch and let the framework do its thing. That is what I did.
Joe
That is OK. Just so you understand the ramifications of your decision - you can't ever use a remote DataPortal for your app. You may not plan to now - but you won't ever be able to in the future if a use case comes up where it is required. If you are fine with that then drive on!
Joe
Copyright (c) Marimer LLC