Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculated Property on BO
Message
From
12/10/2010 13:31:09
 
 
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01485020
Message ID:
01485037
Views:
31
>>This is probably more a plain old .NET question than MM.NET, but MM.NET may have some bearing on it.
>>
>>I have a Policy which has a date Paid Up To which is a calculated value. What is the best way to implement this so that whenever I refer to oPolicy.PaidTo it always has the latest value?
>>
>>I guess I need to create the property as part of the BO:
>>
>>
public DateTime PaidToDate = DateTime.MinValue;
>>
>>(is this the only way to handle null dates?)
>>
>>and a CalculatePaidTo method as part of the BO which returns a date time value which gets called during construction (or should it get called at some other point?)
>>
>>Or should I implement this as a Get/Set thing (which I have a very vague idea how to do so I'll probably be back with questions on that).
>
>From a straight .NET POV, if the value won't change after being initially calculated then something like:
private DateTime? paidToDate;
>        public DateTime PaidToDate
>        {
>            get
>            {
>                if (paidToDate == null)
>                  paidToDate= CalculatedDate();
>                return (DateTime) paidToDate;
>            }
>        }
>        DateTime CalculatedDate()
>        {
>            //return calculated date
>        }
If it will change then simply call CalculatedDate() every time the get{} is accessed.

Thanks,

that's pretty close to what I came up with (I'm so proud of myself <g>)
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Reply
Map
View

Click here to load this message in the networking platform