Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
This will work in a single user scenario, but if you have multiple users, especially if they are all adding new records, you'll get dups pretty quick. The BO is disconnected from the db, so if another user adds a new record after the user has filled the BO, they won't know about the newly added record from the other user. There are a few of solutions for this:
- If possible, just use an AutoIncrement field. The down side is that it is hard to have no holes (in some cases holes are a problem if the field is audited) and it will by a system number, not one that necessarily makes any sense in the context of the business domain.
- Query the db for the last LineOrder number and increment it. I've used this when it is very unlikely that two people are going to be adding records at the same time (in fact, it is a bad idea in these scenarios). Pretty much what you are doing, but if someone else adds new records while the user is in their BO, they'll see the changes.
- Use a table to hand out the LineOrder numbers. I.e. you query this table to get the next line order number. This is more complex because you have to deal with canceled adds, etc.
The long and sort of it is to use the DB to handle this, since the disconnected BO won't know about other users changes in a timely enough fashion (usually). I'm sure there are other ways to do this too, but thought I'd offer some ideas.
|