private void Aggregate(params Type[] entitiesToAggregate_) { if (entitiesToAggregate_.FirstOrDefault(item => item == typeof(enDebate)) != null) { _enComment.Debate_ = new enDebate { ID = _enComment.Debate_ID }; var objBLDebate = new blDebate(_enComment.Debate_); objBLDebate.Read(); } if (entitiesToAggregate_.FirstOrDefault(item => item == typeof(enUser)) != null) { _enComment.User_ = new enUser { ID = _enComment.User_ID }; var objBLUser = new blUser(_enComment.User_); objBLUser.Read(); } if (entitiesToAggregate_.FirstOrDefault(item => item == typeof(enLikeCounter)) != null) { var objENLikeCounter = new enLikeCounter() { Debate_ID = _enComment.Debate_ID, User_ID = _enComment.User_ID }; var objBlLikeCounter = new blLikeCounter(objENLikeCounter); _enComment.listOfLikeCounter = objBlLikeCounter.ReadAll().Where(x => x.Comment_ID == _enComment.ID).ToList(); _enComment.LikesCount = _enComment.listOfLikeCounter.Count; } }
public List <enDebate> ReadAllAndAggregate(int?startRowNumber_ = null, int?endRowNumber_ = null, params Type[] entitiesToAggregate_) { List <enDebate> listOfDebates = ReadAll(startRowNumber_, endRowNumber_); foreach (var item in listOfDebates) { var objBLComment = new blDebate(item); objBLComment.Aggregate(entitiesToAggregate_); } return(listOfDebates); }