如何获取行计数3表连接和lambda表达式?

时间:2012-04-27 15:15:31

标签: linq entity-framework lambda

我正在尝试获取用户具有与特定channelId匹配的报告的行计数。我尝试过没有运气的lambda表达式。

int count = 
_reportsRepository.
    GetMany(r => r.UserId == user.Id && 
    (r.Charts.Any(cr => cr.Channels.Any(ch => ch.Id == channel.Id))).Any()).Count();

enter image description here

1 个答案:

答案 0 :(得分:1)

怎么样?
int count = _reportsRepository.Where( 
                r => r.UserId == user.Id &&
                     r.User.Channels.Any(c => c.Id == channel.Id)).Count();