次のうち、正しいもの、または少なくとも最良のものはどれですか。
コントローラーでデータを取得するメソッドを作成します。
public ActionResult Index()
{
var list = _context.MyClass.Take(10);
return View(list);
}
またはコンテキストを直接使用します。
public ActionResult Index()
{
var list = MyClass.MethodWrapperToGet(10);
return View(list);
}
最初の懸念事項は、データベースが公開されすぎていることです。開発者が誤用しやすくなります。