【发布时间】:2022-01-15 17:39:33
【问题描述】:
我正在创建一个返回LINQ 查询结果的方法。我将其创建为单独的方法,因为多个视图将需要相同的查询。但是我不知道如何创建具有这种返回类型的方法。
public return_type GetData_ById(int? id) // what will be the return type?
{
var student_ = (from z in db.StudModels where z.Status == 10 select z).OrderByDescending(z => z.StudId).ToList();
return student_;
}
public ActionResult CreateCard(int? id)
{
GetData_ById(id);
return View(student_data);
}
GetData_ById 方法的返回类型是什么,然后如何从CreateCard 方法调用函数?
【问题讨论】:
-
如果您将鼠标悬停在
student变量名称上,Visual Studio 将显示类型。
标签: asp.net asp.net-mvc asp.net-mvc-4