0
我得到一個錯誤:我傳遞數據的2個表成一個單一的看法,但我得到一個錯誤
The model item passed into the dictionary is of type 'System.Data.Entity.Infrastructure.DbQuery`1[jetjourneys.ViewModel.ItineraryPage]', but this dictionary requires a model item of type 'jetjourneys.ViewModel.ItineraryPage
代碼:
public class ItineraryPage
{
public PackageGallery Package { get; set; }
public tblItinerary Itinerarydetail { get; set; }
}
public ActionResult ItineraryPackage(int id)
{
using (travelAndTourismEntities objentity = new travelAndTourismEntities())
{
var query = (from x in objentity.tblItineraries
from y in objentity.PackageGalleries
where x.Imageid == id && y.Imageid == id
select new ItineraryPage { Package = y, Itinerarydetail = x });
return View(query);
}
}
這是我的控制器,請幫助我在哪裏,我犯了一個錯誤
這LINQ查詢返回一個'的DBQuery' - 不是實際的,單'ItineraryPage' - 你需要做一個'.FirstOrDefault'或類似的東西在查詢結果中通入風景 –