首页 新闻 会员 周边 捐助

LINQTOSQL

0
悬赏园豆:5 [已解决问题] 解决于 2013-04-11 09:24

将下面SQL语句转换成LINQ(C#)语句或者lambda表达式,谢谢

SELECT Name,
COUNT(Name) AS TIMES
FROM table
WHERE table.Date BETWEEN '2012-04-21' AND '2012-05-23'
GROUP BY table.Name
HAVING COUNT(Name)>10

kingboy8808的主页 kingboy8808 | 初学一级 | 园豆:5
提问于:2012-05-24 14:20
< >
分享
最佳答案
0

又问了啊?下面的代码没有调试,但编译通过,你可以试下。凡事自己变通下,你会发现,编程很有趣。

IQueryable<t> table = null;
var query = from c in table
            where c.Date >= DateTime.Parse("2012-04-21") && c.Date < DateTime.Parse("2012-05-23")
            group c by c.Name into g
            where g.Count() > 0
            select new { Name = g.Key, Times = g.Count() };
收获园豆:5
无之无 | 大侠五级 |园豆:5095 | 2012-05-24 14:33

IQueryable<t> table = null;
var query = from c in table
           
where c.Date >= DateTime.Parse("2012-04-21") && c.Date < DateTime.Parse("2012-05-23")
            group c by c.Name into g
           
where g.Count() > 0
            select new { Name

zhi++ | 园豆:487 (菜鸟二级) | 2013-04-11 19:25
其他回答(1)
0

IQueryable<t> table = null;
var query = from c in table
           
where c.Date >= DateTime.Parse("2012-04-21") && c.Date < DateTime.Parse("2012-05-23")
            group c by c.Name into g
           
where g.Count() > 0
            select new { Name

zhi++ | 园豆:487 (菜鸟二级) | 2013-04-11 19:25
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册