MvcOptions.AllowShortCircuitingValidationWhenNoValidatorsArePresent 屬性

定義

取得或設定值,這個值會決定當模型沒有任何相關聯的驗證程式時,是否 ValidationVisitor 可縮短驗證。

public:
 property bool AllowShortCircuitingValidationWhenNoValidatorsArePresent { bool get(); void set(bool value); };
public bool AllowShortCircuitingValidationWhenNoValidatorsArePresent { get; set; }
member this.AllowShortCircuitingValidationWhenNoValidatorsArePresent : bool with get, set
Public Property AllowShortCircuitingValidationWhenNoValidatorsArePresent As Boolean

屬性值

如果版本是 或更新版本,則預設值 trueVersion_2_2false 否則為 。

備註

當 為 trueHasValidators ,即會判斷模型或其任何屬性或集合專案不能有任何驗證程式、 ValidationVisitor 可以縮短模型的驗證,並將物件圖形標示為有效。 將此屬性設定為 true ,允許 ValidationVisitor 執行此優化。

這個屬性與相容性參數相關聯,而且可以根據應用程式的已設定相容性版本提供不同的行為。 如需設定應用程式相容性版本的指引和範例,請參閱 CompatibilityVersion

藉由呼叫此屬性的 setter,設定相容性參數所需的值,會優先于應用程式 CompatibilityVersion 所隱含的值。

如果應用程式的相容性版本設定為 Version_2_2 ,則除非明確設定此設定,否則此設定將會有 值 true

如果應用程式的相容性版本設定為 Version_2_1 或更早版本,則除非明確設定此設定,否則此設定將會有 值 false

適用於