DataPortal.Create<T> not calling CheckRules

DataPortal.Create<T> not calling CheckRules

Old forum URL:

shawndewet posted on Wednesday, December 14, 2011

I understood that when calling DataPortal.Create<T>(), the object returned will have already had BusinessRules.CheckRules() called on it.  I have my class T with business rules defining that certain fields are required.  Yet the object returned by the DataPortal.Create<T>() method has IsValid == true.  I would expect IsValid == false.  If I manually call obj.BusinessRules.CheckRules() on the returned object, then IsValid is indeed == false.  What am I missing?

RockfordLhotka replied on Wednesday, December 14, 2011

It really isn't the data portal that calls CheckRules, it is the base class DataPortal_Create method.

If you don't invoke the base method then it won't run, and so the CheckRules won't occur.

Copyright (c) Marimer LLC