如何在 PLINQO 中捕获 BrokenRuleException?
创建自定义规则
static partial void AddSharedRules()
{
RuleManager.AddShared<Tag>(
new CustomRule<String>(
"TagName",
"Invalid Tag Name, must be between 1 and 50 characters",
IsNullEmptyOrLarge));
}
我通过添加到我的实体类来
。然后我添加了规则(如视频中所示,尽管视频已注明日期并且包含错误信息):
public static bool IsNullEmptyOrLarge( string value )
{
return (value == null
|| String.IsNullOrEmpty(value)
|| value.Length > 50);
}
但现在我有了调用代码……
try
{
// some code
}
catch ( CodeSmith.Data.Rules… ??? )
{
// I can’t add the BrokenRuleException object. It’s not on the list.
}
我有:分配、安全性和验证。
在 PLINQO 中捕获破坏规则异常的正确方法是什么?
I’ve created a custom rule by adding the
static partial void AddSharedRules()
{
RuleManager.AddShared<Tag>(
new CustomRule<String>(
"TagName",
"Invalid Tag Name, must be between 1 and 50 characters",
IsNullEmptyOrLarge));
}
to my Entity class.
I then added the rule (as seen on the video, although the video is dated and has wrong information):
public static bool IsNullEmptyOrLarge( string value )
{
return (value == null
|| String.IsNullOrEmpty(value)
|| value.Length > 50);
}
But now I have the calling code…
try
{
// some code
}
catch ( CodeSmith.Data.Rules… ??? )
{
// I can’t add the BrokenRuleException object. It’s not on the list.
}
I have: assign, security and Validation.
What’s the correct way to catch broken rule exceptions in PLINQO?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是您需要做的,首先在您的项目中添加对
然后的
引用如果您想更改默认消息,那么您可以转到您的实体并将属性从 更改
为
您还可以使用这些类型的数据注释属性
HTH
Here is what you need to do, first add a reference in your project to
Then
If you want to change the default message then you can go to your entity and change the attribute from
to
You can also use these types of data annotation attributes
HTH