This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I have a situation where I have Parent with details I want to know if it's possible to implement a AutoSum attribute, extension. When the total is changed it should automatically notify the parent to refresh the Order.Total. Currently I have to subscribe to the ListChanged event and then subscribe to each entity in the Entity collections on PropertyChanged event. Which is painful. I was just wondering if there is a way to reduce the complexity from within the LigthSpeed framework.
Johan |
|
|
No, there's nothing in LightSpeed to do this. The usual way to do it in .NET would be to compute the Total property each time it's accessed: public decimal Total { get { return Order.DetailLines.Sum(dl => dl.Total); } } This should suffice unless you need property change notifications or need Order.Total to be a persistent field. |
|
|
Hi Ivan, The total property is persistent as you need to keep track of the total value of the detail lines for auditing and balance check values. Did exactly what you suggested by subscribing to the PropertyChanged event every time entity that were added to the entityCollection and then in the event handler I check if the property is the one that I want to monitor and then I recalculate the total every time the specific values changes. Johan
|
|