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
};
我想将它的输出用作另一个View的局部视图... 我怎么能为它编写控制器.. ActionResult或其他什么......?
答案 0 :(得分:0)
您可以将您的值传递给partialview,首先给出路径,然后传递您的模型,并在局部视图中绑定相关模型!
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