Checking for Duplicate Composite Key in ERLBChecking for Duplicate Composite Key in ERLB
Old forum URL: forums.lhotka.net/forums/t/7372.aspx
esteban404 posted on Thursday, July 30, 2009
Not all my CSLA ref books are with me and I'm not finding what I'm looking for in the forum (yet).
I have a CSLA 3.0.5 ERLB object in a grid. There is a composite key on two fields for each BB item in the list: product and OperationType. If I change/add data and that creates a duplicate combination, the grid sees no errors and data binding fires, no update to the db, but the grid still shows the change.
Since the item is a member of a list of the same type, where do I capture the issue and warn the user? Is there a rule I can set in the list object?
Thanks in advance,
_Eesteban404 replied on Thursday, July 30, 2009
I found no working solutions and tried the suggestions, but none really worked well for the error notification, so I just turned off column fields for the two fields. It would be tantamount to allowing the editing of a primary key and who allows that after a record's committed? So if it's wrong, they delete and recreate it.
So let it be coded...
_Ersbaker0 replied on Thursday, July 30, 2009
What I do is have business rules that do an Exists test on the primary key or key combination.
For either a new object or an existing object whose primary key is dirty, the primary key properties are broken.
(Note that detecting whether an individual property is actually dirty is not a capabillity built into CSLA. I had to implement this myself)esteban404 replied on Monday, August 03, 2009
Thanks rsbaker0. As it turned out, I modified the Exists method to look at the existing list since it's readily available using a simple nested loop. It's damn fast and the sproc provides a second layer of checking just to prevent duplicate insertions without throwing an error in the UI. There are a couple dozen people using the app with a potential to have last write wars.
_E
Copyright (c) Marimer LLC