checking _bypassPropertyChecks in property set?

checking _bypassPropertyChecks in property set?

Old forum URL:

Mudbugz posted on Thursday, January 13, 2011

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);
public string Name
 get { return GetProperty(propName); }
  SetProperty(propName, value);

  if (!InsideOfBypassPropertyChecksBlock)
   // logic such as
   SomeOtherProperty = value;

Should I just use LoadProperty() inside of DataPortal_Fetch instead?

RockfordLhotka replied on Thursday, January 13, 2011

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.

JonnyBee replied on Friday, January 14, 2011


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