2011-02-23 3 views
1

내가 MVC3에 MVC2에서 사이트를 변환하고 나는 그것이 내가 오류 메시지MVC3는 Linq2Sql

"사전에 전달 모델 항목 시스템 '유형 인에 시달리고하고 작업을 진행하게 관리되는 반면 된 나누기. Data.Linq.SqlClient.SqlProvider + SingleResult`1는 [NutritionLabel3.Models.sp_get_ingredientNutritionFoomasResult] NutritionLabel3.Models.sp_get_ingredientNutritionFoomasResult ''하지만,이 사전은 유형의 모델 항목을 요구한다 '. "

이 오류는 모델 층에서 오는 Linq2Sql 데이터 계층을 구현합니다. 이 코드는 MVC2에서 잘 작동합니다. 필자는 새로운 Linq2Sql 인터페이스를 사용하여 MVC3 사이트를 새로 구축함으로써 반복 테스트가 가능한지 확인하기 위해 여러 가지 테스트를 수행했습니다. 컨트롤러에서 Linq2Sql 호출의 일반적인 구현은 다음과 같을 것이다 : 암시 적 타입 변환 메시지가 매우 모호한 것 같다

public ActionResult Index() 
    { 
     NutritionLabel3.Models.testDataContext dbContext = new Models.testDataContext(); 

     var nutritionData = dbContext.sp_get_ingredientNutritionFoomas(2, 1, 2); 

     return View(nutritionData); 
    } 

. MVC3에서 아직이 전투에 참가한 사람이 있습니까?

도움이 될 것입니다!

PatC

답변

1

시도 :

var nutritionData = dbContext 
    .sp_get_ingredientNutritionFoomas(2, 1, 2) 
    .Single();