English 中文(简体)
如何适用商业规则?
原标题:How and when to apply business rules?

附录一

ChangeState(State toState, DomainObject object)

我有业务规则,检查目的地国是否有效,或是否属于目前“状态”的范畴,我如何在技术上检查这些规则,而没有首先确定目标领域的国家? 它对新国家的首个感到错,如果一个或多个规则中断,国家

One solution I came up with is to create some context object that drives the validation eg. ChangeStateContext that contains the DomainObject along with the State that is to be set.

Another related question is how to report back from the ChageState call how it went?
I can collect all validation rules that broke and throw an exception with those rules that the caller can catch and handle accordingly or I can add a return type on the ChangeState-method like ValidationSummary that contains information about broken rules and such. What is best practices in these cases?

问题回答

当国家变革无效时,你能否从<代码>ChangeState方法中排除一个例外情况? 您可以提出具体的例外,例如<条码>《国家转变》/代码>或<条码>,您可在电话上排得更高的位置。 你可以选择性地将额外性质列入这些例外类型,以便你能够非常准确地向用户通报错误。

当你想在单一用户行动之后呼吁多个变革国家时,你将需要一种办法,来恢复或退步。 我通常采用的是工作模式单位(通过LINQ至Q和实体框架向我提供),并在工作单位内改变所有状态。 当一个例外被推翻时,我放弃了完整的工作单位及其所有变化。

www.un.org/Depts/DGACM/index_french.htm 如果<代码>到国家是从主题<编码>目前状态的有效过渡,则类别可采用<条码>(国家)查询方法。 这种方法可在<代码>之前使用。 Stateservice.ChangeState calls.

当然,如果<条码>国家服务负责国家变革验证,则应在<条码>上添加<条码>。 Stateservice。

为报告验证错误信息,修改<代码>的回归类型。 CanChange State to atom打字,负责报告验证错误。





相关问题
Bind Button.IsEnabled to custom validation with XAML?

I am sorry I didn t know how to title my question any better, you name it if you got a good 1. I have an entity Contact. this person has navigation properties: Address, Phones (A collection of Phone)....

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

Wpf Combobox Limit to List

We are using Wpf Combobox to allow the user to do the following things: 1) select items by typing in the first few characters 2) auto complete the entry by filtering the list 3) suggesting the first ...

Rails 101 | validates_currency?

I ve searched high and low, but I could not find a solution, to what I think seems like a very common task. In a form I want to have a text input that accepts currency strings (i.e. $1,000,000 or ...

CodeIgniter form verification and class

I m using the form validation library and have something like this in the view <p> <label for="NAME">Name <span class="required">*</span></label> <?...