求助,linq简化
本帖最后由 yj258213056 于 2013-12-13 11:38:25 编辑 哪位大哥帮忙看看下面的代码怎么简化,关键是这句
XpoSession.FindObject<CheltemInInfo>(CriteriaOperator.Parse("RFID=?", m.RFID))
var data = sendDetails.Select(m => new
{
CheltemName = XpoSession.FindObject<CheltemInInfo>(CriteriaOperator.Parse("RFID=?", m.RFID)).CheltemBaseInfo.ChineseName,
ProductSpec = XpoSession.FindObject<CheltemInInfo>(CriteriaOperator.Parse("RFID=?", m.RFID)).SupplierProductSpe,
RFID = m.RFID,
CabinetCode = m.CabinetSendDataInfo.CabinetCode,
DangerousLevel = XpoSession.FindObject<CheltemInInfo>(CriteriaOperator.Parse("RFID=?", m.RFID)).CheltemBaseInfo.DangerousLevel,
InTime = XpoSession.FindObject<CheltemInInfo>(CriteriaOperator.Parse("RFID=?", m.RFID)).InTime,
Remark = XpoSession.FindObject<CheltemInInfo>(CriteriaOperator.Parse("RFID=?", m.RFID)).Remark
});
return data.ToList();
var data= from m in sendDetails
let x=XpoSession.FindObject<CheltemInInfo>(CriteriaOperator.Parse("RFID=?", m.RFID))
select new
{
CheltemName = x.ChineseName,
ProductSpec = x.SupplierProductSpe,
RFID = m.RFID,
CabinetCode = m.CabinetSendDataInfo.CabinetCode,
DangerousLevel = x.CheltemBaseInfo.DangerousLevel,
InTime = x.InTime,
Remark = x.Remark
}
return data.ToList();