0
嗨我想獲得這個linq查詢的計數。我使用實體框架與存儲庫模式。 可能通過queryUserWalls.ToList()。Count() 得到結果,我認爲這是低效的。 任何身體都可以幫忙。用連接和聯合計數查詢
var queryUserWalls = (from participation in _eventParticipationRepository.GetAll()
join eve in _eventRepository.GetAll() on participation.EventId equals eve.Id
join userWall in _userWallRepository.GetAll() on participation.EventId equals userWall.EventId
where participation.UserId == userId
select userWall.Id)
.Union(from userWall in _userWallRepository.GetAll()
select userWall.Id);
爲什麼不能直接執行'.Count()'? (no'.ToList()') – xanatos
爲什麼你不能調用'queryUserWalls.Count()'? – MarcinJuraszek