comment puis-je fusionner 2 table en 1 vue Ceci est mes modèles.comment joindre 2 table avec asp.net mvc4
namespace ProfileApplication.Models
{
using System;
using System.Collections.Generic;
public partial class EMP
{
public string EMP_ID { get; set; }
public string EMP_NAME { get; set; }
public string EMP_LNAME { get; set; }
}
public partial class X_EMP_MAIL
{
public string EMP_ID { get; set; }
public string EMAIL { get; set; }
}
ceci est mon Controtller.
public class profileController : Controller
{
//
// GET: /profile/
ProfileEntities db = new ProfileEntities();
public ActionResult Index()
{
return View(db.EMP.ToList());
}
public ActionResult detail(string id = null)
{
var query = from EMP in db.EMP
join X_EMP_MAIL in db.X_EMP_MAIL on EMP.EMP_ID
equals X_EMP_MAIL.EMP_ID
where X_EMP_MAIL.EMP_ID == EMP.EMP_ID
select new joinproflie
{
EMP_ID = EMP.EMP_ID,
EMP_NAME = EMP.EMP_NAME,
EMP_LNAME = EMP.EMP_LNAME,
EMAIL = X_EMP_MAIL.EMAIL
};
if (query == null)
{
return HttpNotFound();
}
return View(query);
}
ceci est mon avis
@model IEnumerable<ProfileApplication.Models.EMP>
@foreach (var item in Model)
{
<tr>
<td>@item.EMP_ID </td>
<td>@item.EMP_NAME </td>
<td>@item.EMP_LNAME </td>
<td>@item.EMAIL </td>
<!-- -->
</tr>
<br/>
}
comment dois-je faire?