0
string currentUserId = User.Identity.GetUserId(); 

var us = from u in db.Users 
      join s in db.Designations 
      on new { id = u.DesignationID } equals new { id = s.DesignationID } 
      where u.Id == currentUserId 
      select new ViewEmployees 
      { 
       EmployeeCode = u.UserName, 
       EmployeeName = u.Name, 
       Father_Name = u.Father_Name, 
       DesignationName = s.DesignationName, 
       EmployeeType = u.EmployeeType, 
       Email = u.Email, 
       Mobile = u.Mobile 
      }; 

다른 뷰에서 부분보기로 출력을 사용하고 싶습니다 ... 어떻게 컨트롤러를 쓸 수 있습니까? ActionResult 또는 다른 오류 .... ....?어떻게 부분보기에 대한 작업을 작성 하시겠습니까?

답변

0

부분보기에 값을 전달한 다음 경로를 지정한 다음 모델을 전달하고 부분보기에서 관련 모델을 바인딩 할 수 있습니다.

public ActionResult YourMethodName() 
    { 
    ViewEmployees us = from u in db.Users 
         join s in db.Designations 
         on new { id = u.DesignationID } equals new { id = s.DesignationID } 
         where u.Id == currentUserId 
         select new ViewEmployees 
         { 

          EmployeeCode = u.UserName, 
          EmployeeName = u.Name, 
          Father_Name = u.Father_Name, 
          DesignationName = s.DesignationName, 
          EmployeeType = u.EmployeeType, 
          Email = u.Email, 
          Mobile = u.Mobile 

         }; 

     return PartialView("~/PartialViewName", us); 
    } 

하고 부분보기에

@model eHRManager.Models.ViewEmployees 
+0

Err0r :: 사전에 전달 모델 항목 유형 'System.Web.Mvc.PartialViewResult'이지만,이 사전은 유형의 모델 항목을 필요로 'eHRManager.Models.ViewEmployees'@Neel –

+0

업데이트 된 답변 .. 이제 업데이트 됨 @ Usman407 – Neel

+0

같은 오류 .. @Neel –