Hi,
I was wondering if anyone has done this before so I wont spend too much time reinventing the wheel.
My EditableRootObject "Contract" has a Child List of "Payments" and I need to add a bunch of "Payments" to that child list based on a specific criteria. The dark side of the story is that the due date of each of these payments objects needs a lot of interaction with database to exclude several dates which are physically stored or calculated.
That makes me think that this proces should run as close to the Data tier as possible... in fact, it could be done inside a stored procedure.
Now, what is driving me crazy is how to create those objects at server side and send them to UI (Silverlight) to insert them into the child list.
So far, I've been thinking on creating a separated ReadOnlyList for transportation only and manually add each item to the child list inside the BO... But, something makes me thing that there is a better approach for this situation...
What are your thoughs?
Jean Paul
Presuming that you do choose to create your objects "server side", you could use a Command object that returns the list of children, and then manually insert them into your list - in other words, your suggested solution is probably going to be the best one. However, before you go down that road, you might want to do some testing to see whether doing that is really as poorly-performing as you think. Unless these exclusionary dates change quite frequently, you could probably pre-load and cache the list, thus allowing for a more natural programming model without creating a bunch of networking overhead.
HTH
- Scott
Hi Scott,
I really appreciate your answer. Regarding pre-loading those exclusionary dates... You're right this would be a more natural programming model but it is what it is... I tried but there are many other conditions around this.
The solution I finally came with is an ReadOnlyListBase(Of GeneratedList, Payment) with an asynchronous Factory method that calls DataPortal.Fetch using a criteria parameter and, on server side DataPortal_Fetch add New Payments to the collection.
Finally, on client side, I has to add retrieved Items to the child collection "by hand".
Now, the use of a command instead of a ReadOnlyListBase (Reusing original child list type "Payments") sounds really cool since it'll keep a better level of abstraction in my project... I'll switch to this approach later.
Thank you very much!
JP
Copyright (c) Marimer LLC