C#4.0のcustomvalidation属性を使用してカスタム検証メソッドを作成しました。私はEntity Framework 4.1のコードを使用しています。ただし、カスタム検証属性メソッドは静的です。同じクラス内の他の非静的フィールドを参照しながら、クラス内の他のロジックを検証するにはどうすればよいですか。データの注釈とコードを使用したカスタム検証属性
すなわち
public class Foo
{
[CustomerValidation(typeOf(Foo), "ValidatePoints"]
public string Points { get; set; }
public string AdvancedPoints { get; set;}
public static ValidationResult ValidatePoints(string _Name)
{
if (_Name != AdvancedPoints) //Note that AdvancedPoints here is non-static and should not be here. but i want to know how i can achieve this.
{
return ValidationResult.Success;
}
else
return new ValidationResult("Wrong entry");
}
}