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引擎为基础

你可能感兴趣的:(LINQ)