首页 新闻 赞助 找找看

获取话题/新闻详情,同时获取该信息的阅读数/关注数,请问linq该怎么写?

0
[待解决问题]

话题表Topics(id,types,title),话题关注表Topicfocus(id,Topicid,types,mid,addtime)

获取话题/新闻详情,同时获取该信息的阅读数/关注数,请问linq该怎么写?

1 var query= (
2     from A in Topics where A.Id==99 && A.Types==1
3     select new{A.Id,A.Title,A.Mid}
4 ).Concat(
5     (from B in Topicfocus where B.Topicid==99 && B.Types==1 
6     select new{B.Mid}).Distinct().Count()
7 );
8 
9 query.Dump();

我这样写,第4行或报错!参数 2: 无法从“int”转换为“System.Collections.Generic.IEnumerable<AnonymousType#1>”

问题补充:

我想要的实际查询SQL语句是类似这样的:

select A.id,A.title,
    (select COUNT(distinct(mid)) from topicfocus where topicid=A.id and types=A.types) as 'focusnumber' 
from topics as A 
where A.id=99 and A.types=2;

返回的结果包括三个字段:id,title,关注阅读总数

熊仔其人的主页 熊仔其人 | 菜鸟二级 | 园豆:212
提问于:2016-01-07 11:15
< >
分享
所有回答(1)
0

还是直接加个列就好啦.这样太费啦

关注的时候+1就是了

吴瑞祥 | 园豆:29449 (高人七级) | 2016-01-07 11:38
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册