Exception handling 如何在PLINQO中捕获BrokenRuleException?

Exception handling 如何在PLINQO中捕获BrokenRuleException?,exception-handling,plinqo,Exception Handling,Plinqo,我通过添加 static partial void AddSharedRules() { RuleManager.AddShared<Tag>( new CustomRule<String>( "TagName", "Invalid Tag Name, must be between 1 and 50 characters",

我通过添加

 static partial void AddSharedRules()
 {
            RuleManager.AddShared<Tag>(
                new CustomRule<String>(
                    "TagName",
                    "Invalid Tag Name, must be between 1 and 50 characters",
                    IsNullEmptyOrLarge));
 }
但现在我有了呼叫代码

try    
{    
    // some code
}
catch ( CodeSmith.Data.Rules… ??? )
{

// I can’t add the BrokenRuleException object. It’s not on the list.
}
我有:分配、安全和验证


在PLINQO中捕获违反规则的异常的正确方法是什么?

以下是您需要做的事情,首先在项目中添加一个对

System.ComponentModel.DataAnnotations

using CodeSmith.Data.Rules;
然后

还可以使用这些类型的数据注释属性

    [StringLength(10, ErrorMessage= "The name cannot exceed 10 characters long")]
    [Range(10, 1000, ErrorMessage = "Value for {0} must be between {1} and {2}.")]
    [RegularExpression(@"^[a-zA-Z''-'\s]{1,40}$", ErrorMessage = "Characters are not allowed.")]
    public string FirstName { get; set; }

HTH

以下是您需要做的事情,首先在您的项目中添加一个对

System.ComponentModel.DataAnnotations

using CodeSmith.Data.Rules;
然后

还可以使用这些类型的数据注释属性

    [StringLength(10, ErrorMessage= "The name cannot exceed 10 characters long")]
    [Range(10, 1000, ErrorMessage = "Value for {0} must be between {1} and {2}.")]
    [RegularExpression(@"^[a-zA-Z''-'\s]{1,40}$", ErrorMessage = "Characters are not allowed.")]
    public string FirstName { get; set; }

HTH

太好了,现在我的脑海中出现了价格合适的主题曲。太好了,现在我的脑海中出现了价格合适的主题曲。谢谢里波,像往常一样,你在这里和@PLINQO论坛上都帮了大忙。谢谢里波,像往常一样,你在这里和@PLINQO论坛上都帮了大忙。
[CodeSmith.Data.Audit.Audit]
private class Metadata
{
    // Only Attributes in the class will be preserved.

    public int NameId { get; set; }

    [Required(ErrorMessage="please please please add a firstname!")]
    public string FirstName { get; set; }
    [StringLength(10, ErrorMessage= "The name cannot exceed 10 characters long")]
    [Range(10, 1000, ErrorMessage = "Value for {0} must be between {1} and {2}.")]
    [RegularExpression(@"^[a-zA-Z''-'\s]{1,40}$", ErrorMessage = "Characters are not allowed.")]
    public string FirstName { get; set; }