linq where条件是方法的时候怎么处理
例如:
C# code
var contracts = from c in db.B_Contract_Out
join h in db.B_Hospital on c.HospitalID equals h.ID into ch
where c.C4 == "1"
where c.ContractDate>=startDate && c.ContractDate<=backDate// 想在这再加个条件 就是GetQianKuan(Convert.ToDouble(c.AllMoney), c.ID)!=0 怎么处理
from chs in ch.DefaultIfEmpty()
join u in db.sys_User on c.PrincipalUser equals u.UserID into cu
from cus in cu.DefaultIfEmpty()
orderby c.ContractDate descending
join p in db.B_PayRecord on c.ID equals p.ContractID into cp
from cps in cp.DefaultIfEmpty()
where c.AllMoney != Convert.ToDouble(cps.PayMoney)
orderby c.ContractDate descending
select new { ArmNames = GetArmariumName(c.ID), ArmOutPrice = GetArmOutPrice(c.ID), c.ID, c.ContractDate, c.ContactNum, cus.U_CName, c.AllMoney, chs.HospitalName, qiankuan = GetQianKuan(Convert.ToDouble(c.AllMoney), c.ID) };
等待...
------解决方案--------------------
或者这样:
var contracts = from c in db.B_Contract_Out
join h in db.B_Hospital on c.HospitalID equals h.ID into ch
where c.C4 == "1"
where c.ContractDate>=startDate && c.ContractDate<=backDate
from chs in ch.DefaultIfEmpty()
join u in db.sys_User on c.PrincipalUser equals u.UserID into cu
from cus in cu.DefaultIfEmpty()
orderby c.ContractDate descending
join p in db.B_PayRecord on c.ID equals p.ContractID into cp
from cps in cp.DefaultIfEmpty()
where c.AllMoney != Convert.ToDouble(cps.PayMoney)
orderby c.ContractDate descending
select new { ArmNames = GetArmariumName(c.ID), ArmOutPrice = GetArmOutPrice(c.ID), c.ID, c.ContractDate, c.ContactNum, cus.U_CName, c.AllMoney, chs.HospitalName, qiankuan = GetQianKuan(Convert.ToDouble(c.AllMoney), c.ID) };
contracts =contracts.ToList().Where(c=> GetQianKuan(Convert.ToDouble(c.AllMoney), c.ID)!=0);