LINQ to datatable 链接查询
List<DoctorQueue> lst = new List<DoctorQueue>();
try
{
DataSet ds = DBHelper.ExecuteDataSet("exec API_GetDoctorQueue '" + fhp_id + "','" + fDeptId + "'");
DataTable dt1 = ds.Tables[0];
DataTable dt2 = ds.Tables[1];
lst = (from a in dt2.AsEnumerable()
join b in dt1.AsEnumerable()
on new { temp = a.Field<int>("fID") } equals new { temp = b.Field<int>("fDoctorID") }
into temp
from t in temp.DefaultIfEmpty()
select new DoctorQueue
{
fID = a.Field<int>("fID"),
fDoctorName = a.Field<string>("fDoctorName") == null ? "" : a.Field<string>("fDoctorName"),
fDeptName = a.Field<string>("fDeptName") == null ? "" : a.Field<string>("fDeptName"),
fTitle = a.Field<string>("fTitle") == null ? "" : a.Field<string>("fTitle"),
fSpecialty = a.Field<string>("fSpecialty") == null ? "" : a.Field<string>("fSpecialty"),
fQueueNum = a.Field<int>("fQueueNum"),
fAverageWaitingTime = a.Field<int>("fAverageWaitingTime"),
fIsOnLine = t.Field<bool>("fIsOnLine"),//Convert.ToBoolean(t["fIsOnLine"])也可
fImgUrl = a.Field<string>("fImgUrl") == null ? "" : a.Field<string>("fImgUrl")
}).ToList<DoctorQueue>();
}
catch { }
return lst;
a为主表
浙公网安备 33010602011771号