Skip to main content
.NET 6.0+

IRuleSource.CreateRules() Method

Instantiates custom Validation Rules.

Namespace: DevExpress.Persistent.Validation

Assembly: DevExpress.Persistent.Base.v24.1.dll

Declaration

ICollection<IRule> CreateRules()

Returns

Type Description
ICollection<IRule>

An ICollection<IRule> object, which represents custom Validation Rules.

Remarks

When implementing the IRuleSource interface, use this property to supply the Validation Module with custom Validation Rules.

To see an example of the IRuleSource interface implementation, refer to the “Custom Rule Source” section of the Declare Validation Rules topic.

Note

In .NET applications, you need to use the DevExpress.Persistent.Validation.Extensions.IRuleSource.CreateRules(IRuleSet ruleSet) extension method instead of IRuleSource.CreateRules() to access the IRuleSet service in a persistent validation rule class’s CreateRules method implementation.

A persistent validation rule implementation cannot use Dependency Injection to access services in a CreateRule method’s implementation because at the time this method is invoked, the rule object’s Session.ServiceProvider (XPO) or IObjectSpace.ServiceProvider (EF Core) object is already disposed of.

For an example on how to implement this extension method, see: IRuleSource: Example.

See Also