话题表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,关注阅读总数
还是直接加个列就好啦.这样太费啦
关注的时候+1就是了