我在表格中为每个类别设置了类别列和歌曲列。将近 10 首歌曲,总共有 7 个类别,因此它被列为
category1 songCategory1a
category1 songCategory1b
category1 songCategory1c
---
---
--
category2 songCategory2a
category2 songCategory2b
category2 songCategory2c
---
---
---
category3 songCategory3a
category3 songCategory3b
category3 songCategory3c
---
---
---
就像有一个表,我想在其中得到结果
类别 1 类别2 类别3 类别4
我试过:
(from s in _context.db_songs
select new { s.Song_Name, s.Song_Category }).Distinct().ToList();
但是没有用。结果就是这样。
请您参考如下方法:
当您需要获取不同的行时,您只需提供您想要从中获取不同数据的列:
(from s in _context.db_songs
select s.Song_Category ).Distinct().ToList();
