Skip to main content
.NET 6.0+

RuleCombinationOfPropertiesIsUniqueAttribute.MessageTemplateCombinationOfPropertiesMustBeUnique Property

Specifies the text to be written in the Validation Error window when the current rule is broken.

Namespace: DevExpress.Persistent.Validation

Assembly: DevExpress.Persistent.Base.v23.2.dll


public string MessageTemplateCombinationOfPropertiesMustBeUnique { get; set; }

Property Value

Type Description

A string value representing the text to be written to the Validation Error window when a rule is broken.


When defining a RuleCombinationOfPropertiesIsUnique rule via the RuleCombinationOfPropertiesIsUniqueAttribute in code or in the Model Editor, you can specify a custom definition to be displayed in the Vaidation Error window for the broken rule. To do this, set the CustomMessageTemplate property. However, the list of the found objects will not be displayed. To display them, specify the MessageTemplateCombinationOfPropertiesMustBeUnique property instead of the CustomMessageTemplate property. The following code demonstrates this:

using DevExpress.Persistent.BaseImpl.EF;
using DevExpress.Persistent.Validation;
using System;
using System.Linq;

    DefaultContexts.Save, "Description, Company",
    MessageTemplateCombinationOfPropertiesMustBeUnique =
    "Objects with the same combinations of the " +
    "'Description' and 'Company' properties must not exist.")]
public class SampleClass : BaseObject {
    public virtual string Company { get; set; }
    public virtual string Description { get; set; }

// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.

To customize the format that is used to list the found objects in the Validation Error window, use the RuleCombinationOfPropertiesIsUniqueAttribute.FoundObjectMessageFormat and RuleCombinationOfPropertiesIsUniqueAttribute.FoundObjectMessagesSeparator properties.

There is a set of format items you can use in message templates. For instance, when using the {TargetObject} format item, the validated object will be inserted at runtime. For details, refer to the RuleBaseAttribute.CustomMessageTemplate property description.

See Also