I'm working on a side project. One of the design decisions is that components shouldn't do any database calling (if this is wrong or impractical then i'mI'm open to disregarding this design policy). I'm also using radzen component library, but has no bearing on this.
So i
I have a button component that is basically two buttons. one for save (a sub part of an object), and a dropdown/context button to save all (all aspects of a more complex object). this button component is a component and can be used in multiple places. so my idea is to pass the save methods to the button from a parent page. but what's happening in practice is that the save component is a child in another component. this is no big deal, the page defines the save methods, passes it to the component which then passes to the child. where things get hairy is that the method definition is not really definable on the button. sometimes i'mI'm passing a func<Task>
other times i'm passing func<myType,Task>
. so to account for this is i'mI'm setting the method as a dynamic and calling invoke on that. Here's how that looks.
soOo this all works, but having to use the dynamic type to circumvent strong typing generates a code smell from a (potentially bad) design policy caused by not wanting components to make out of process calls (database updates), and only having pages define methods that make that make out of process calls. Is Is my design policy fine and this is just one of the things iI need to do, or should iI abandon the policy (on this early project).?