If I use BypassPropertyChecks in my DataPortal_Fetch() to set properties from the database, how to I stop logic in the setting of the property from running? _bypassPropertyChecks is private inside of BusinessBase. Sample Code:
//Inside of Dataportal_Fetch()
using (BypassPropertyChecks)
{
Name = db.Name;
...
}
private static PropertyInfo<string> propName = RegisterProperty<string>(p => p.Name);
[Required]
[StringLength(50)]
public string Name
{
get { return GetProperty(propName); }
set
{
SetProperty(propName, value);
if (!InsideOfBypassPropertyChecksBlock)
{
// logic such as
SomeOtherProperty = value;
}
}
}
Should I just use LoadProperty() inside of DataPortal_Fetch instead?
CSLA is designed with the intent that the only line of code in a setter is the call to SetProperty. All other logic should be encapsulated in business rules, which are automatically invoked and suppressed when following the CSLA coding patterns.
Hi,
Your properties should only be Get/Set with no other code. Remember, properties are not code.
Depending on which CSLA version you are using, you should:
Csla 3.8.x and older versions
Csla 4.x and newer
Copyright (c) Marimer LLC