private static List<Question> GetQuestionsForTestCategory(Category testCategory) { var allCategories = context.Categories.ToList(); var allQuestions = context.Questions.ToList(); var categories = GetQuestionCategories(testCategory, allCategories); var questions = (from q in allQuestions where categories.Exists(x => x.Name == q.Category.Name) select q).ToList(); return questions; }
private static List<Category> GetQuestionCategories(Category testCategory, IList<Category> allCategories) { var categories = new List<Category> { testCategory, allCategories.FirstOrDefault(x => x.Name == "DB"), allCategories.FirstOrDefault(x => x.Name == "OOP"), allCategories.FirstOrDefault(x => x.Name == "English") }; return categories; }