Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load, Update and Save, or execute Insert/Update sql commands directly?

I've got this process which happens when a user wants to void a check.

Each Check contains multiple PayableCheck records, and multiple Error records

Check.CheckID = PayableCheck.CheckID
Check.CheckID = Error.CheckID

Each PayableCheck matches up with 1 Payable record.

PayableCheck.PayableID = Payable.PayableID

Each Payable corresponds with a Receipt or an Error

Error.PayableID = Payable.PayableID
Receipt.PayableID = Payable.PayableID

When a user voids a Check (given a Check ID#), I need to:

  1. Set the Check status to V
  2. Create another Check with negative of the original check's amount
  3. Create another Error for each Error associated with the original check, each Error having the negative amount
  4. Set the Active field to 0 for each PayableCheck linked to the original Check
  5. Set each linked Payable to status O
  6. Set each linked Error to status O, and each linked Receipt to status O

Am I better off loading everything in using Entity Framework and making the changes in C# and then saving, or is there a better approach using just sql updates and inserts?

like image 226
Tony Peterson Avatar asked Sep 02 '26 13:09

Tony Peterson


1 Answers

Better create a stored procedure in sql server and write all the sql's which should do the purpose.

like image 54
ProgrammerBoy Avatar answered Sep 04 '26 03:09

ProgrammerBoy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!