Linq to SQL,三表联合查询,结果包含三个表的混合数据,如何获得记录总数?
语句如下,我知道目前的结果和News表的记录数一样,但是加上条件筛选后如何获得查询结果的记录总数?publicIQueryableFindAllNews(){return...
语句如下,我知道目前的结果和News表的记录数一样,但是加上条件筛选后如何获得查询结果的记录总数?
public IQueryable FindAllNews()
{
return from n in db.NewsModel
join b in db.BigClassModel on n.BigClassID equals b.BigClassID
join s in db.SmallClassModel on n.SmallClassID equals s.SmallClassID
orderby n.AddTime descending
select new
{
n.NewsID,
n.BigClassID,
n.SmallClassID,
n.Title,
b.BigClassName,
s.SmallClassName,
};
} 展开
public IQueryable FindAllNews()
{
return from n in db.NewsModel
join b in db.BigClassModel on n.BigClassID equals b.BigClassID
join s in db.SmallClassModel on n.SmallClassID equals s.SmallClassID
orderby n.AddTime descending
select new
{
n.NewsID,
n.BigClassID,
n.SmallClassID,
n.Title,
b.BigClassName,
s.SmallClassName,
};
} 展开
展开全部
var q= from n in db.NewsModel
join b in db.BigClassModel on n.BigClassID equals b.BigClassID
join s in db.SmallClassModel on n.SmallClassID equals s.SmallClassID
orderby n.AddTime descending
select new
{
n.NewsID,
n.BigClassID,
n.SmallClassID,
n.Title,
b.BigClassName,
s.SmallClassName,
};
return q.ToList();
q.Count()//这个就是记录总数
join b in db.BigClassModel on n.BigClassID equals b.BigClassID
join s in db.SmallClassModel on n.SmallClassID equals s.SmallClassID
orderby n.AddTime descending
select new
{
n.NewsID,
n.BigClassID,
n.SmallClassID,
n.Title,
b.BigClassName,
s.SmallClassName,
};
return q.ToList();
q.Count()//这个就是记录总数
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询