Sum of LineItems #3182
Answered
by
kcabral817
Chicagoan2016
asked this question in
Questions
Sum of LineItems
#3182
Replies: 4 comments 6 replies
-
Do you need a property on the parent? I wonder if instead you can dynamically sum the totals from the child collection. |
Beta Was this translation helpful? Give feedback.
2 replies
-
Beta Was this translation helpful? Give feedback.
1 reply
-
You have some options then. You can perform the calculation in the save method, business rule, or in the view model. However, I would still lean towards a business rule and then you can leverage that rule if the business rule changes and folks want it calculated real-time or at some other point in the process flow.
Here are two methods that I use to intercept a property change value and perform some work. These are in my business class and you can add an if statement to check for the property that has the values and then sum them and do it real time.
protected override void PropertyHasChanged(IPropertyInfo property)
{
base.PropertyHasChanged(property);
BusinessRules.CheckRules();
BusinessRules.CheckObjectRules();
}
protected override void OnChildChanged(ChildChangedEventArgs e)
{
base.OnChildChanged(e);
BusinessRules.CheckRules();
}
I invoke the business rule stream but you can sum the values and they will be displayed when changed.
Regards,
Kevin
From: ***@***.***>
Sent: Wednesday, November 2, 2022 9:31 AM
To: ***@***.***>
Cc: Kevin ***@***.***>; ***@***.***>
Subject: Re: [MarimerLLC/csla] Sum of LineItems (Discussion #3182)
You mean without a rule?
—
Reply to this email directly, view it on GitHub<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMarimerLLC%2Fcsla%2Fdiscussions%2F3182%23discussioncomment-4039805&data=05%7C01%7C%7C743b89403f354dc5b66708dabcefa909%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638030034756602568%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2BJqQ8NC33L1OQwBZpaJUcAgHu4SzNwfQ7BAlDWrrfD4%3D&reserved=0>, or unsubscribe<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGJTVDUEINLS4K5LWXRTD3DWGKJNFANCNFSM6AAAAAARUOV5CQ&data=05%7C01%7C%7C743b89403f354dc5b66708dabcefa909%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638030034756602568%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=fY8y0F7YA3eb4gHwElJvV8uI7aBRZnNgPjFigsoJbOk%3D&reserved=0>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Chicagoan2016
-
There are times when a specific property changes that I want to invoke the rules. This was mainly for WPF and my not be applicable to Blazor |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
We are migrating a non-csla application to Csla. We have line items (collection) contained in an order object.
How should we implement total amount of line items contained in a particular order object? A business rule that gets called when we save the order object and update a property 'Totalamount'?
Regards
Beta Was this translation helpful? Give feedback.
All reactions