- 唯一约束
- 单属性唯一约束,在属性上写:
private Evaluation _RelEvaluation;
[RuleUniqueValue("关联评测活动不能重复", DefaultContexts.Save, CriteriaEvaluationBehavior = CriteriaEvaluationBehavior.BeforeTransaction)]
[XafDisplayName("关联评测活动")]
public Evaluation RelEvaluation
{
get
{
return _RelEvaluation;
}
set
{
SetPropertyValue("RelEvaluation", ref _RelEvaluation, value);
}
}
- 复合唯一约束,多个属性,在类上写
[DefaultClassOptions]
//[NavigationItem("基础管理")]
[XafDisplayName("评价人")]
[ImageName("BO_Person")]
[CreatableItem(false)]
[RuleCombinationOfPropertiesIsUnique("同一测评活动下评价人的密码不能重复", DefaultContexts.Save, "RELEvaluation, Pwd")]
public class Appraiser : BaseObject
{ // Inherit from a different class to provide a custom primary key, concurrency and deletion behavior, etc. (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument113146.aspx).
public Appraiser(Session session)
: base(session)
{
}
- 必填项
private MemberDomainObject _RELMemberDomainObject;
[RuleRequiredField(DefaultContexts.Save)]
[Association("MemberDomainObject-CPSCLDO")]
[XafDisplayName("关联会员")]
public MemberDomainObject RELMemberDomainObject
{
get { return _RELMemberDomainObject; }
set
{
SetPropertyValue("RELMemberDomainObject", ref _RELMemberDomainObject, value);
}
}