Web Connection
wwBusinessObject::Load and composite PK
Gravatar is a globally recognized avatar based on your email address. wwBusinessObject::Load and composite PK
  Ivan Koci
  All
  Mar 12, 2025 @ 09:39am

Hi Rick, I have to perform a CRUD operation on a SQL Server table that has a composite primary key defined. I've been following described under the "Step 6 - Adding, editing and deleting customers from the customer list". Finally, I have no idea how to implement the wwBusinesObject::load? E.g. how to specify all key columns as a PK parameter? Please advice how to proceed.

Gravatar is a globally recognized avatar based on your email address. re: wwBusinessObject::Load and composite PK
  Rick Strahl
  Ivan Koci
  Mar 12, 2025 @ 02:20pm

Much of the automatic load/save functionality in wwBusiness will not work without a true primary key, so you'll need to override the behavior of these methods.

Custom loading is pretty easy: You can create a new method (or override (.Load()) and in that method you can call .LoadBase() with a filter expression that uses your compound key fields.

For Save() however there's no simple workaround - you pretty much need to either create custom logic or copy the code from the base .Save() method and customize the update logic that checks the filter expressions or pk update logic.

Compound keys tend to be a bad idea for many reasons - this is one of them 😄

+++ Rick ---

© 1996-2025