我該如何將其轉換爲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