I am a little curious about the inner workings of the CommandBase. I've researched as much as I could before posting this but am still a little confused about some of the inner workings of the DataPortal_Execute Method that is implemented. How is it different from how the DataPortal routes for things like Create or Fetch? And are there any repercussions to calling this from some other DataPortal method (i.e. like from inside DataPortal_Create).
The only difference I can really see from where i'm sitting, is that this CommandBase allows you to create methods with return types other than the Csla object (like the Exists() method in ProjectTracker). However, I'm sure there's more to it. I remember reading in the book that this DataPortal_Execute puts less load on the server end somehow... is this true? if so how?
Thanks for any help in advance
The load on the server is entirely up to you - it depends on what you put into the DataPortal_Execute() method. The CSLA "load" is the same for all objects that flow through the data portal.
I've discussed this in previous threads - you can accomplish much the same thing with a ReadOnlyBase object as you can with a CommandBase object. In fact I resisted adding Execute() to the data portal for years.
The joke is this: the data portal does CRUD (create,read,update,delete) and to add execute would be CRUDE :)
All that happens with a command object is that it flows through the data portal, and the DataPortal_Execute() runs, then the command object comes back to the client through the data portal.
All that happens with a ReadOnlyBase object is that its criteria flows through the data portal, and the DataPortal_Fetch() runs, then the read-only object comes back to the client through the data portal.
The only difference is that with a command object, there's just one object (the command) that goes from client to server to client. With a read-only object there are two: criteria and read-only. The criteria goes from client to server, and the read-only object goes from server to client.
Arguably the ReadOnlyBase option is more efficient, since you have more direct control over what data flows each direction.
People get confused writing "command" logic in a DataPortal_Fetch() method though, so using a command object is more clear because the logic is in DataPortal_Execute().
Copyright (c) Marimer LLC