Code Changes Second Opinion. #2145
Replies: 1 comment
-
Is this all running as part of a transaction? Then you're probably OK. This is more of a Sql question than a Csla question, but I would bet most of us using Csla are also working with Csla databases. I have a different technique to suggest. Declare a table variable in your statement and use the OUTPUT clause to insert AutoGeneratedIdentityValue into the table variable. You can then use the table variable in your select and in your second insert statement. With this technique, you can handle scenarios where multiple rows are being generated and you might want to record the identity of all the records that were inserted. Here's a sample syntax I tested out on our audit log table, which has column LogId as an identity column.
All of that can go into your CommandText string. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am currently in charge of supporting a very mission critical application developed using the CSLA. This application is so critical that to be honest, I am becoming more and more paranoid about any updates I make to the application that I consider to be "core" updates. No matter how much testing I do, I still loose sleep over those types of changes. That said, I was hoping to get a second option on some changes we are introducing to get some peace of mind.
Looking at the sample code below:
Do you see any potential issues with the reliability of the code above? Specifically, do you see a problem (some corner case issue) that may be caused by the last insert?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions