public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) { var db = new 客戶資料Entities(); var data = db.客戶資料.Find(this.客戶Id); foreach (var item in data.客戶聯絡人) { if (item.Email.Equals(this.Email) && (bool)!this.是否已刪除) { yield return new ValidationResult("電子郵件重複", new[] { "Email" }); } } }
public EFUnitOfWork() { Context = new 客戶資料Entities(); }