Linq的Join用法

直接上例子吧

var plist=ViewBag.plist as IEnumerable<ZKX.Model.PatientInfo>;
var cert= ViewBag.certsource as IEnumerable<ZKX.Model.CertTypeInfo>;

//join到一个新的匿名对象
var pext=plist.Join(cert, m => m.CERTTYPE_NO, t => t.CERTTYPE_NO, (m, t) => new { patient = m, cert = t });

//使用
<td>@item.patient.CUST_NAME</td>
<td>@item.patient.SEX</td>
<td>@item.cert.CERTTYPE_NAME</td>
<td>@item.patient.CERTCODE</td>
<td>@item.patient.RELATIONMOBILE</td>

//本例是以razor引擎为基础
posted @ 2012-03-15 21:06  $walker  阅读(440)  评论(0编辑  收藏  举报