Share via


DbContext.GetValidationErrors メソッド

[このページは、Entity Framework 6 に関するページです。最新バージョンは、'Entity Framework' NuGet パッケージとして入手できます。Entity Framework の詳細については、msdn.com/data/ef を参照してください。]

追跡対象のエンティティを検証し、その検証結果を格納した DbEntityValidationResult のコレクションを返します。

名前空間:  System.Data.Entity
アセンブリ:  EntityFramework (EntityFramework.dll 内)

構文

'宣言
<SuppressMessageAttribute("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")> _
Public Function GetValidationErrors As IEnumerable(Of DbEntityValidationResult)
'使用
Dim instance As DbContext 
Dim returnValue As IEnumerable(Of DbEntityValidationResult)

returnValue = instance.GetValidationErrors()
[SuppressMessageAttribute("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
public IEnumerable<DbEntityValidationResult> GetValidationErrors()
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1024:UsePropertiesWhereAppropriate")]
public:
IEnumerable<DbEntityValidationResult^>^ GetValidationErrors()
[<SuppressMessageAttribute("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")>]
member GetValidationErrors : unit -> IEnumerable<DbEntityValidationResult> 
public function GetValidationErrors() : IEnumerable<DbEntityValidationResult>

戻り値

型 : System.Collections.Generic.IEnumerable<DbEntityValidationResult>
無効なエンティティに対する検証結果のコレクション。コレクションが null になることはありません。また null 値または有効なエンティティの結果を格納することもできません。

解説

1. このメソッドは、DbContextConfiguration.AutoDetectChangesEnabled が false に設定されていない限り、DetectChanges() を呼び出して追跡対象エンティティの状態を特定します。 2. 既定では、Modified エンティティに対する Added のみが検証されます。 ShouldValidateEntity メソッドをオーバーライドすることで、この動作を変更できます。

参照

参照

DbContext クラス

System.Data.Entity 名前空間