1-) C# MVC - Lazy ve Eager Loading
1-) C# MVC - Eager için join yapmak aşağıdaki gibidir
using System.Linq;
using System.Web.Mvc;
using WebApplication2.Models.EntityFramework;
using System.Data.Entity;
namespace WebApplication2.Controllers
{
public class PersonelController : Controller
{
PersonelDBEntities db = new PersonelDBEntities();
// GET: Personel
public ActionResult Index()
{
var model = db.personel.Include(x=>x.departman).ToList();
return View(model);
}
}}
2-) Lazy için join yapmak aşağıdaki gibidir

3-) table da göstermek ise
@model List<WebApplication2.Models.EntityFramework.personel>
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Personel Listesi</h2>
<table class="table table-bordered">
<thead>
<tr>
<th>Ad</th>
<th>Soyad</th>
<th>Doğum Tarihi</th>
<th>Departman</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@item.ad</td>
<td>@item.soyad</td>
<td>@item.dogumTar.Value.ToString("dd-MM-yyyy")</td>
<td>@item.departman.ad</td>
</tr>
}
</tbody>
</table>