2012-09-29 5 views
0

MVC 응용 프로그램이 있고 두 엔티티가 있습니다.LINQ 쿼리가 제대로 작동하지 않습니다.

엔티티 리드는 고객을 상속합니다.

enter image description here

이제 리드 컨트롤러 인덱스보기에서, 나는 코드 아래에 쓴

...

public ViewResult Index() 

     {  

      var Leads = (from c in db.Customers.OfType<CRMEntities.Lead>() 
         where(c.IsActive == true) select c); 

      return View(Leads.ToList()); 

     } 

나는 인덱스보기에서 아래의 코드가 있습니다.

@model IEnumerable<CRMEntities.Lead> 

@{ 
    ViewBag.Title = "Index"; 
} 

<h2>Index</h2> 
. 
. 

레코드가없는 레코드가 테이블에 있습니다. 검색어가 맞나요?

전체보기 코드

@model PagedList.IPagedList<CRMEntities.Lead> 


@{ 
    ViewBag.Title = "Index"; 
} 

<h2>Index</h2> 

<p> 
    @Html.ActionLink("Create New", "Create") 
</p> 
<table> 
    <tr> 
     <th> 
      Status 
     </th> 
     <th> 
      IsQualified 
     </th> 
     <th> 
      Name 
     </th> 
     <th> 
      Address 
     </th> 
     <th> 
      OfficePhone1 
     </th> 
     <th> 
      Website 
     </th> 
     <th> 
      Email2 
     </th> 
     <th> 
      Email1 
     </th> 
     <th> 
      FaxNo 
     </th> 
     <th> 
      Remark 
     </th> 
     <th> 
      Rating 
     </th> 
     <th> 
      BusinessType 
     </th> 
     <th> 
      IsActive 
     </th> 

    </tr> 

@foreach (var item in Model) { 
    <tr> 
     <td> 
      @Html.DisplayFor(modelItem => item.Status) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.IsQualified) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.Name) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.Address) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.OfficePhone1) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.Website) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.Email2) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.Email1) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.FaxNo) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.Remark) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.Rating) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.BusinessType) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.IsActive) 
     </td> 

     <td> 
      @Html.ActionLink("Edit", "Edit", new { id=item.Id }) | 
      @Html.ActionLink("Details", "Details", new { id=item.Id }) | 
      @Html.ActionLink("Delete", "Delete", new { id=item.Id }) 
     </td> 
    </tr> 
} 

</table> 

답변

0

쿼리 볼 수있는 것과 잘 보인다.

표시중인 코드에 아무 것도 표시되지 않습니다. 뷰에 @ Model.Count()를 써서 가지고있는 레코드의 수를 확인하십시오.

데이터베이스 프로파일 러가없는 경우 가져 오는 것이 좋습니다.

+0

답장을 보내 주셔서 감사합니다. 제 질문을 업데이트했습니다. 전체보기 코드를 추가했습니다. 확인해주십시오. – user1668543

+0

보기가 좋아 보인다. 통합 테스트를 작성하여 해당 쿼리에 대한 결과를 다시 얻을 수 있는지 확인할 수 있습니까? 또는 인덱스 뷰에 중단 점을 넣어서 반환되는 것을 볼 수 있습니다. 단순히 리드가없는 것처럼 보입니다. – dove

관련 문제