读书人

Linq 求转换。

发布时间: 2012-12-15 15:16:03 作者: rapoo

Linq 求转换。 在线等。
select parent_id,COUNT(parent_id) from book_topic
where book_id = 7757 and parent_id is not null
group by parent_id
[最优解释]
var source=from t in db.class1 where t.book_id==7757&&t.parent_id!=DBNull.Value group t by t.parent_id into g select new{parent_id=g.Key,count=g.Count()};
[其他解释]
var source=from t in db.class1 where t.book_id==7757&&t.parent_id!=DBNull.Value group t by t.parent_id into g select new{parent_id=g.Key,count=t.Count()};
没有测试
[其他解释]

引用:
var source=from t in db.class1 where t.book_id==7757&&t.parent_id!=DBNull.Value group t by t.parent_id into g select new{parent_id=g.Key,count=t.Count()};
没有测试


g.key 是什么意思?
[其他解释]
VAR QUERY=FROM b IN book_topic
WHERE b.book_id==7757 && t.parent_id != null
group by t.parent_id into g
select new {t.parent_id=g.key,count=g.count()}
[其他解释]
count 变量哪来的? 实体类里没有啊~
[其他解释]
var stufftype =


引用:
count 变量哪来的? 实体类里没有啊~


count为重定义的实体对象名称,可自命名之!

...
select new {parent_id=g.key,count=g.count()}

读书人网 >asp.net

热点推荐