我有Id rptQuestionbank的Repetaer。我尝试使用orderby属性,但我总是得到一些语法错误。我只想按升序排序RptQuestionbank.DataSource。 请帮助M新来LINQ 请告诉我在哪里可以学习这些基本技能的良好链接。
public void bindDetails()
{
using (var surveykshanentities = new SurveyKshanEntities())
{
int SessionId = Convert.ToInt16(Session["SurveyId"]);
RptQuestionbank.DataSource = surveykshanentities.SurveyKshan_QuestionBank
.Where(x => !surveykshanentities.SurveyKshan_SurveyQuestion.Any(y =>
y.QuestionId == x.QuestionId &&
y.SurveyId == SessionId))
.ToList();
RptQuestionbank.DataBind();
}
}
答案 0 :(得分:1)
最后我经过如此多的打击和试验,我自己做了。
RptQuestionbank.DataSource =
surveykshanentities.SurveyKshan_QuestionBank
.Where(x => !surveykshanentities.SurveyKshan_SurveyQuestion.Any(y =>
y.QuestionId == x.QuestionId &&
y.SurveyId == SessionId))
.ToList()
.OrderByDescending(p => p.QuestionText);