这是我在类文件中的代码,我如何在我的 xaml.cs 中调用它(后面的代码)?
//Get all records based on ActivityID and TaskID and Group By ActivityID , TaskID , QuestionNo.
public IList<QuestionHint> GetRecords1(int listTask, int listActivity)
{
IList<QuestionHint> lstRecords = context.questionhints.GroupBy(x => new { x.QuestionNo, x.ActivityID, x.TaskID }).ToList().Select(g => new QuestionHint()
{
QuestionNo = g.Key.QuestionNo,
ActivityID = g.Key.ActivityID,
TaskID = g.Key.TaskID
}).Where(q => q.TaskID == listTask && q.ActivityID == listActivity)
//.Take(50)
.ToList();
return lstRecords;
}
public class QuestionHint
{
public int? QuestionNo { get; set; } //change the type accordingly
public int? ActivityID { get; set; } //change the type accordingly
public int? TaskID { get; set; } //change the type accordingly
public string Answer { get; set; } //change the type accordingly
public string QuestionContent { get; set; } //change the type accordingly
public string joined { get; set; } //change the type accordingly
public string joinOption { get; set; } //change the type accordingly
}
这就是我尝试在 WPF 后面的 xaml.cs 代码中使用此方法的方式:
IList<QuestionHint> lstQuestionHints = qh.GetRecords(taskID, activityID);
但是错误说找不到 QuestionHint 但我已经像这样声明它:
private DAO.DAOQuestionHint qh = new DAO.DAOQuestionHint();
我正在使用带有 lambda 表达式的实体框架,DAOQuestionHint 是类文件的名称。