Esempio n. 1
0
        public IReadOnlyCollection <NodeCandidate> GetNodeCandidatesBySession(SessionOfExperts session)
        {
            var totalExpectCount = new GetExpertCountQuery(_linqProvider).Execute(
                new GetExpertCountSpecification(session));

            return(_linqProvider.Query <Association>()
                   .Where(x => x.Expert.SessionOfExperts == session)
                   .GroupBy(x => new { x.Notion, TypeName = x.Type.Name, TypeId = x.Type.Id })
                   .Select(
                       gr => new NodeCandidate
            {
                Notion = gr.Key.Notion,
                TypeId = gr.Key.TypeId,
                TypeName = gr.Key.TypeName,
                ExpertCount = gr.Count(),
                TotalExpert = totalExpectCount
            })
                   .ToList());
        }
Esempio n. 2
0
        public IReadOnlyCollection <GroupedRelation> GetGroupedRelations(SessionOfExperts sessionOfExperts)
        {
            var totalExpectCount = new GetExpertCountQuery(_linqProvider).Execute(
                new GetExpertCountSpecification(sessionOfExperts));

            var relations = _linqProvider.Query <Relation>()
                            .SelectMany(x => x.Types, (relation, type) => new { relation.Source, relation.Destination, Type = type })
                            .ToList();

            return(relations
                   .GroupBy(x => new { x.Source, x.Destination, x.Type })
                   .Select(
                       gr => new GroupedRelation
            {
                Source = gr.Key.Source,
                Destination = gr.Key.Destination,
                Type = gr.Key.Type,
                ExpertCount = gr.Count(),
                TotalExpectCount = totalExpectCount
            })
                   .ToList());
        }