Exists and Null object pattern in Csla #3426
Replies: 2 comments
-
We in the end also skipped the Exists pattern, we call the Fetch operation but instead of the PK we check the IsNew flag to check if the operation succeeded |
Beta Was this translation helpful? Give feedback.
-
The thing about the Exists pattern is that it is a convenience for the user, it isn't really a known solution due to optimistic concurrency. In other words, you don't know that the value is unique until it has been put into the database. Some other user could have clicked save at the same moment, and then you have a race condition as to which one "wins". This is usually rare though, so the Exists pattern often provides the user with a better overall experience at the cost of a second round-trip to the app server and db. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am looking at an existing Csla application, this application was written years ago.
Although we use 'Exists' pattern (similar to project tracker) to find out if a record e.g Employee exists in our database. We do that before we try to upload the whole object graph.
I noticed that Csla data portal returns essentially a 'Null' object with no (or default) values. In our objects, the primary key property in null objects is always zero.
Will it be okay to skip the 'Exists' pattern for 'single' root objects and just call the Fetch operation and check the primary key property of the object? That will save us some code in the future : )
Regards
Beta Was this translation helpful? Give feedback.
All reactions