0

너무 this answer에보고, MVC 4의 "부분 검증 기술"을 구현해야 할 것 :MVC 4 : 부분 검증 기술을 사용하는 방법은 무엇입니까?

 public class DontValidateEmailAttribute : ActionFilterAttribute 
     { public override void OnActionExecuting(ActionExecutingContext filterContext) 
       { 
        var modelState = filterContext.Controller.ViewData.ModelState;  
        var incomingValues = filterContext.Controller.ValueProvider;  
        var key = modelState.Keys.Single(x => incomingValues.Equals("Email")); 
        modelState[key].Errors.Clear(); 
        } 
      } 

하지만 다음 컴파일 오류 수 :

"... 'System.Collections.Generic.ICollection<string>' does not contain a definition for 'Single' and no extension method 'Single' accepting a first argument of type 'System.Collections.Generic.ICollection<string>' could be found (are you missing a using directive or an assembly reference?)을"

THX

+1

위로 System.Linq를 사용하여 위로 가기가 빠졌습니까? – gideon

+0

정말 고마워요! 그것은 효과가 있었다. 당신이 대답을하면 나는 기꺼이 유효한 답신으로 표시합니다. – Larry

답변

1

상단에 using System.Linq이 누락 되었습니까?

+0

효과가있었습니다. 고맙습니다! – Larry

+0

:) 오신 것을 환영합니다! – gideon