私は次のコードを持っています。
エラーは次の行にあります。if (testinstances == null)
testinstances という名前は、現在のコンテキストには存在しません。
このエラーの原因は何ですか?
public ActionResult Index(int? classRoomId, int? courseId, int? testTypeId)
{
var classRoom = cls.GetAll();
var course = cos.GetAll();
var testType = tst.GetAll();
ViewBag.ClassRoomID = new SelectList(classRoom, "ClassRoomID", "ClassRoomTitle");
ViewBag.CourseID = new SelectList(course, "CourseID", "Title");
ViewBag.TestTypeID = new SelectList(testType, "TestTypeID", "TestTypeDesc");
if (classRoomId == null || courseId == null || testTypeId == null)
{
var testinstances = tt.GetAll();
}
else
{
var testinstances = tt.GetAll().Where(t => t.TestTypeID == testTypeId &&
t.ClassRoomID == classRoomId &&
t.CourseID == courseId);
}
if (testinstances == null)
{
throw new ArgumentNullException("No Test Found.Do you want to create one?");
RedirectToAction("Create");
}
return View(testinstances.ToList());
}