我在网上看了一些文章,对于一些简单的linq 可以用expression来拼 ,但是仍然不知道复杂的如何来拼,难道真需要用那种极其复杂的繁琐的表达式树,一点点的拼起来吗?那不是噩梦么?
如下: from tohos in
orgCancel(start, end)
group tohos by new { tohos.RESERVE_TIME.Year, Half = (tohos.RESERVE_TIME.Month - 1) / 6 }
into gs
select new
{
gs.Key,
Group = gs.GroupBy(c => new
{
c.RESERVE_TIME.Year,
c.RESERVE_TIME.Month,
c.RESERVE_TIME.Day
}
).Select(d => new
{
d.Key,
Count = denoReservePatientCount(start, end, d.Key.Year, d.Key.Month, d.Key.Day, d.Count())
})
}
protected double denoReservePatientCount(DateTime start, DateTime end, int Year, int Month, int Day, int num)
{
return num == 0 ? 0 : 100d * (double)num /
denoReservePatient(start, end).Where(c => c.RESERVE_TIME.Year == Year && Month == c.RESERVE_TIME.Month && Day == c.RESERVE_TIME.Day
).Count();
}
protected IQueryable<ReserveSex> denoReservePatient(DateTime start, DateTime end)
{
var q = from r in _analysisEntity.RESERVE_TBL
join p in _analysisEntity.PATIENT_TBL on r.RS_PATIENT_ID equals
p.PB_PATIENT_ID
where r.RESERVE_TIME >= start && r.RESERVE_TIME < end && p.BIRTHDAY != null
select new ReserveSex { CONTACT = r.CONTACT, NET_RESERVE = r.NET_RESERVE, RESERVE_TIME = r.RESERVE_TIME, RS_PATIENT_ID = r.RS_PATIENT_ID, PB_SEX_ID = p.PB_SEX_ID, BIRTHDAY=p.BIRTHDAY };
请教一下各位大大,denoReservePatientCount 这个方法其实在表达式树的解析中会出错,报说linq to entites 无法解析这个方法,但是我的sql统计中大量存在 比如denoReservePatientCount的方法,那我该怎么来拼接他呢?
万分感激~~
denoReservePatient方法在哪??返回的是什么类型?