November Happy Hour will be moved to Thursday December 5th.

Get answered questions by expert

Vote:
 

Hi,

We have a query that gives us answered question by expert. This is the function:

 

        public static AssignedQuestionCollection GetAnsweredQuestionsByExpert(int expertId, int pageSize, int page, out int totalItems, SortingDirection sortingDirection)
        {
            AnswerQuery answerQuery = new AnswerQuery();

            answerQuery.AssignedQuestion = new AssignedQuestionCriterion();
            answerQuery.AssignedQuestion.Expert = new ExpertCriterion();
            answerQuery.AssignedQuestion.Expert.ID = new IntegerCriterion();
            answerQuery.AssignedQuestion.Expert.ID.Value = expertId;

            answerQuery.Created = new DateTimeCriterion();
            answerQuery.OrderBy.Add(new CriterionSortOrder(answerQuery.Created, sortingDirection));

            QueryHandler.RemoveQueryResultCache(answerQuery);
            AnswerCollection answers = QueryHandler.GetQueryResult<Answer, AnswerCollection>(answerQuery, page, pageSize, out totalItems);

            AssignedQuestionCollection assignedQuestionCollection = new AssignedQuestionCollection();

            foreach (var answer in answers)
            {
                assignedQuestionCollection.Add(answer.AssignedQuestion);
            }

            return assignedQuestionCollection;
        }

 

We wish to rebuild this query to handle many expert id's. Any ideas how to use this function (or other solutions) to get many many experts answered question in a AssignedQuestionCollection list?

 

Regards,

Magnus

#45205
Nov 02, 2010 14:30
Vote:
 

We solved it. And here is the solution:

Added the following (see the rest above):

answerQuery.AssignedQuestion.Expert.ID.Includes = new IntegerInCriterion();
answerQuery.AssignedQuestion.Expert.ID.Includes.Values.Add(expertid);

foreach (int id in experts)
{
    answerQuery.AssignedQuestion.Expert.ID.Includes.Values.Add(id);
}

#45352
Nov 04, 2010 14:29
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.