Is there an elegant way to write an insert statement, which has a lot of parameters? I have like 20 flags that need to be saved in the DB, plus other information that also require to be inserted, along with those 20 flags. Writing a method with 30 parameters for that insert is a waste of time, but so far I haven't come up with other ideas, that might work.
You can put all these parameters in an object and pass that object to the method.
A standard approach is to create a class representing your entity and then pass around an instance of that class.
This makes it easy to pass to other methods that may do validation, presentation, etc., as well as persistence.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With