저는 MVC 3.0 및 LINQ to SQL에 초보자입니다. 저장 프로 시저를 호출하고 결과를 VAR로 저장했지만 현재 VIEW에서 데이터를 보는 방법은 무엇입니까?보기에서 컨트롤러 데이터보기
CODE :
using EmployeeAttendance_app.Models;
namespace EmployeeAttendance_app.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "Employee Attendance";
var DataContext = new EmployeeAtdDataContext();
var EmployeeAtd = DataContext.GetAttendance_Sp;
return View(EmployeeAtd);
}
public ActionResult About()
{
return View();
}
}
}
SP :
Select * from V_EmpAtd
보기 :
@foreach (GetAttendance_SpResult emp in (IEnumerable<Object>)ViewData.Model)
{
<li>@emp.DeptName</li>
}
이 뷰가 성공적으로 결과를 보여줍니다 :)하지만 난 이해하지 않는 내가 할 이유 foreach에서 "GetAttendance_SpResult"가 필요합니다.
return View(EmployeeAtd);
컨트롤러와 관련이 있습니까?
도움이 되시면 – James
MVC에 대한 자습서를 읽어 보시기 바랍니다. http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/intro-to-aspnet- mvc-3 – Marthijn
독자가 뭔가를하고 있지만 뭔가를해야만한다. – James