I have a non-crud method that needs to always run on the data portal. How do I force the method to always run on the data portal?
Not sure if this answers your question, but there is a command object in Csla that is normally used to execute queries that do not return Csla objects. Look at the Exists object in Project Tracker. This can be used to execute any logic, not just database related.
Jon Stonecash
Jon,
With this approach, will I use DataPortal.Execute to pass the command? If yes, how would I return values from the command back to the client?
What version of Csla are you using?
In your class, you can use the DataPortal_OnDataPortalInvoke and Child_OnDataPortalInvoke and add a method call. This will execute the method every time as part of the dataportal operation.
If you have an inhered framework, just add the necessary overrides there, if not, then you can add it directly to your business objects.
Chris
Chris,
Thanks for the response. I'm not looking to fire a method everytime a DataPortal call is invoked, but rather to execute a specific method only on the DataPortal. Something like:
DataPortal.Execute(()=>this.SomeNonCRUDMethod());
This is exactly what the command object stereotype is designed to handle, but in an object oriented manner rather than a procedural manner.
The Using CSLA 4: Creating Business Objects ebook covers all the stereotypes, as does the older Expert 2008 Business Objects book. The Exists command implementations in ProjectTracker demonstrate the concept, though with the DataPortal_Execute method doing some data access - but it is a pretty minor thing to consider that the method would just perform server-side algorithmic processing instead.
Are objects in the command object serialized back to the client? For example, if I was calling a sproc with out params, how would I return those values back to the client. Is it as simple as updating the values in the command object?
The FAQ has a topic on the Unit of Work concept, which is what you are looking for
http://www.lhotka.net/cslanet/faq/CslaObjectFaq.ashx
Ah, gotcha. The Command object will work well for you. Have you tried it yet? From what your describing it fits the need.
Copyright (c) Marimer LLC