linq
每种数据不重复随机提取3条。
id type name
1 a aaa
2 a aab
3 a aac
4 a aad
5 a aae
6 b bbb
7 b bbc
8 b bbd
9 b bbe
10 b bbf
11 b bbg
------解决方案--------------------table.GroupBy(x => x.type).SelectMany(x => x.OrderBy(y => Guid.NewGuid()).Take(3));
------解决方案--------------------什么样的数据算“重复”?
说说你想要的结果是个什么样
------解决方案--------------------table.GroupBy(x => x.type).Select(x => x.OrderBy(y => new { type = x.Key, rnd3 = Guid.NewGuid()).Take(3).ToList() });