首页 > 代码库 > linq 的switch实现

linq 的switch实现

List<RemindSend> lrs = (from a in db.Remind
join b in db.Certified
on a.certifiedId equals b.CertifiedId
where a.status == 1 && a.addTime.Year == DateTime.Now.Year && a.addTime.Month == DateTime.Now.Month && a.addTime.Day == DateTime.Now.Day
select new RemindSend
{
cerfiedid = b.CertifiedId,
queueCode = b.QueueCode,
queueNum = b.QueueNum,
openid = a.openid,
remindPerson = b.QueueCode.Substring(0, 1) == "F" ?
db.Certified.Where(c => c.Status == 1 && c.GetTime.Year == DateTime.Now.Year && c.GetTime.Month == DateTime.Now.Month && c.GetTime.Day == DateTime.Now.Day && c.QueueNum < b.QueueNum && c.QueueCode.StartsWith(b.QueueCode.Substring(0, 1))).Count()
: b.QueueCode.Substring(0, 1) == "B" ?
db.Certified.Where(c => c.Status == 1 && c.GetTime.Year == DateTime.Now.Year && c.GetTime.Month == DateTime.Now.Month && c.GetTime.Day == DateTime.Now.Day && c.QueueCode.StartsWith("F")).Count() +
db.Certified.Where(c => c.Status == 1 && c.GetTime.Year == DateTime.Now.Year && c.GetTime.Month == DateTime.Now.Month && c.GetTime.Day == DateTime.Now.Day && c.QueueNum < b.QueueNum && c.QueueCode.StartsWith(b.QueueCode.Substring(0, 1))).Count()
: b.QueueCode.Substring(0, 1) == "A" ?
db.Certified.Where(c => c.Status == 1 && c.GetTime.Year == DateTime.Now.Year && c.GetTime.Month == DateTime.Now.Month && c.GetTime.Day == DateTime.Now.Day && c.QueueCode.StartsWith("F")).Count() +
db.Certified.Where(c => c.Status == 1 && c.GetTime.Year == DateTime.Now.Year && c.GetTime.Month == DateTime.Now.Month && c.GetTime.Day == DateTime.Now.Day && c.QueueCode.StartsWith("B")).Count() +
db.Certified.Where(c => c.Status == 1 && c.GetTime.Year == DateTime.Now.Year && c.GetTime.Month == DateTime.Now.Month && c.GetTime.Day == DateTime.Now.Day && c.QueueNum < b.QueueNum && c.QueueCode.StartsWith(b.QueueCode.Substring(0, 1))).Count()
: 1,
remindid = a.remindid
}).ToList();

linq 的switch实现