Can I have a field on a BusinessBase that is locked for the user but allows the object itself to update? For instance, I have a field this is calculated based on the values of 2 other fields. So Field3 = Field 1 + Field2. I don’t want the user to be able to update Field 3 but I want logic in the BusinessBase to update the field. If I use AuthorizationRules.AllowWrite to prevent the user from modifying the field, I get an error saying my logic cannot update it either. Is there an easy way around this? Thanks.
Jonathan
I would declare this property as read-only property and just
update backing field for it and raise PropertyChanged event at that time to
signal UI that a change occurred.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: jfreeman
[mailto:cslanet@lhotka.net]
Sent: Friday, October 31, 2008 4:23 PM
To: Sergey Barskiy
Subject: [CSLA .NET] Authorization Rules Question
Can I have a field on a BusinessBase that is locked for the user but allows
the object itself to update? For instance, I have a field this is
calculated based on the values of 2 other fields. So Field3 = Field 1 +
Field2. I don???t want the user to be able to update Field 3 but I want
logic in the BusinessBase to update the field. If I use
AuthorizationRules.AllowWrite to prevent the user from modifying the field, I
get an error saying my logic cannot update it either. Is there an easy
way around this? Thanks.
Jonathan
Right now I using managed fields. Is there a way to handle it with them or do I have to using backing fields to make it work? Thanks.
Jonathan
If you display the field with WinForms databinding, however, I'm not sure if LoadProperty will update your property being displayed though. I think that's why Sergey mentioned the PropertyHasChanged.
But I've been doing WebForms so I may not be remembering correctly.
I guess, I will elaborate on my suggestion:
Public int Field3
{
Get {return GetProperty(Field1Property) + GetProperty(Field2Proprty)}
}
Public int Field1
{
Set
{
SetProperty(Field1Property, value); OnPropertyChanged(“Field3”);
}
Same for Field2
Something like this. This way you do not need to worry
about maintaining Field3 – it is always in-memory computation only.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: ajj3085
[mailto:cslanet@lhotka.net]
Sent: Friday, October 31, 2008 4:46 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: Authorization Rules Question
LoadProperty will skip security checks.
Copyright (c) Marimer LLC