我正在学习linq。
我在 sql server 中有:
create table Something(id int, num int)
insert into Something(id, num) values(1, 10);
insert into Something(id, num) values(1, 10);
insert into Something(id, num) values(2, 7);
insert into Something(id, num) values(2, 7);
insert into Something(id, num) values(2, 7);
insert into Something(id, num) values(3, 5);
insert into Something(id, num) values(3, 5);
insert into Something(id, num) values(3, 5);
insert into Something(id, num) values(3, 5);
insert into Something(id, num) values(3, 5);
insert into Something(id, num) values(3, 5);
insert into Something(id, num) values(4, 5);
select id
from something
group by id, num
having count(*) < num
结果是:4、2和1
我正在尝试使用 linq:
var query =
(from m in lst
group m by new { m.id, m.num } into g
where g.Count() < m.num).ToList();
我想将 g.Count() 与“num”字段进行比较,但我的代码有问题
感谢您的帮助!