我该如何将其转换为LINQ?在LINQ中选择案例
select t.age as AgeRange, count(*) as Users
from (
select case
when age between 0 and 9 then ' 0-25'
when age between 10 and 14 then '26-40'
when age between 20 and 49 then '60-100'
else '50+' end as age
from user) t
group by t.age
谢谢!
可能的重复 - HTTP:// stackoverflow.com/questions/936028/linq-case-statement,http:// sta ckoverflow.com/questions/209924/switch-statement-in-linq,http://stackoverflow.com/questions/436028/linq-to-sql-case-query,http://stackoverflow.com/questions/936028/ linq-case-statement – pavanred 2010-11-22 09:53:59
如果有人遇到这个问题,并想知道“他们之间有什么区别”只有一个是,也许是重复的是:stackoverflow.com/questions/436028/linq-to-sql-case-query和它没有在标题中指定范围,但它是答案。其他人仅限于个案陈述,但在特定情况下。在实际问题中标记的答案与范围没有任何关系,因为问题指定了...所以... – user1040975 2017-08-01 19:20:50