When to call ValidationRules.CheckRules() in CSLA 3.5?

When to call ValidationRules.CheckRules() in CSLA 3.5?

Old forum URL: forums.lhotka.net/forums/t/5772.aspx


alef posted on Monday, November 10, 2008


Do we need to call Validation.Checkrules() in the Child_Create() method.
In 2.1 we need to do that. Is this not anymore the case in 3.5?

eg. ProjectResource

protected override void Child_Create()
{
    LoadProperty<SmartDate>(AssignedProperty, new SmartDate(System.DateTime.Today));
    Validation.Checkrules();   ?????
}

sergeyb replied on Monday, November 10, 2008

Either this or you can call the base method (which is what I do), as in base.Child_Create() which does call ValidationRules.CheckRules();

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: alef [mailto:cslanet@lhotka.net]
Sent: Monday, November 10, 2008 9:11 AM
To: Sergey Barskiy
Subject: [CSLA .NET] When to call ValidationRules.CheckRules() in CSLA 3.5?

 


Do we need to call Validation.Checkrules() in the Child_Create() method.
In 2.1 we need to do that. Is this not anymore the case in 3.5?

eg. ProjectResource

protected override void Child_Create()
{
    LoadProperty<SmartDate>(AssignedProperty, new SmartDate(System.DateTime.Today));
    Validation.Checkrules();   ?????
}



k2so replied on Monday, November 10, 2008

That's where I call mine.

You want to call it here, if you want a validation check every time the child object gets created, one reason being that the UI can show information that's required but missing in order to direct user to input.

I believe, someone said it somewhere before, that Child_Create in the BusinessBase class already has a Validation.CheckRules call in it, and if you do not override Child_Create, that method would be called by default upon a child creation and Validation.CheckRules gets called in it.

Copyright (c) Marimer LLC