csla 中的异步验证规则
有谁有在 csla 中实现异步验证规则的简单示例吗?
我已经查看了 Rolodex 示例中 Company 类中的示例,但这对我来说并不是特别清楚:为什么我需要命令类?
我在 WPF 应用程序中使用 csla 3.8。
Does anyone have a simple example of implementing an async validation rule in csla?
I have looked at the example in the Company class in the Rolodex sample but this isn't particularly clear to me: why do I need a command class?
I'm using csla 3.8 in a WPF application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我想出了如何做到这一点,但最终结果证明答案打开了一大堆蠕虫。
将异步规则添加到您的业务类:
AddRule 的第一个参数是一个委托,如下所示:
该委托依次调用 DuplicateUserNameCommand,这是您需要创建的新类型:
就是这样。我遇到的问题是Command的DataPortal_Execute中的所有代码都需要是线程安全的。就我而言,这导致了严重的问题,所以现在我恢复到同步规则。
OK I figured out how to do this, but in the end it turned out that the answer opened a rather large can of worms.
Adding the Async rule to your business class:
The first arg for AddRule is a delegate shown below:
The delegate in turn calls a DuplicateUserNameCommand which is new type you need to create:
That's about it. The problem that I encountered is that all the code in Command's DataPortal_Execute needs to be thread safe. In my case this caused severak issues so for now I'm reverting back to synchronous rules.