首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

Linq 求转换。

2012-12-15 
Linq 求转换。 在线等。select parent_id,COUNT(parent_id) from book_topic where book_id 7757 and pare

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()}

热点排行