我的问题是添加创建页面时,它来自哪里? db.AddToMovies(newMovie)-它给出了构建错误(下面的Contoller代码)?
这是从Visual Studio 2019列出,创建和编辑SQL表的最佳方法吗?
谢谢, EB
我已经在控制器页面上添加了它。那是SP还是数据库中的东西? db.AddToEmployees(newEmployee);给这个问题。 这不是我要自定义的代码:
IntranetEntities db = new IntranetEntities();
public ActionResult Employees()
{
var employees = from m in db.Employees
select m;
return View(employees.ToList());
}
// GET: Employees/Details/5
public ActionResult Details(int id)
{
return View();
}
// GET: Employees/Create
public ActionResult Create()
{
return View();
}
// POST: Employees/Create
[HttpPost]
public ActionResult Create(Employee newEmployee)
{
if (ModelState.IsValid)
{
db.Employees(newEmployee);
db.SaveChanges();
return RedirectToAction("Employees");
}
else
{
return View(newEmployee);
}
}
答案 0 :(得分:1)
您可以转到上一页,它声明var Map = function () {
this.mapInit();
};
Map.prototype.mapInit = function () {
// do the stuff you want to do
};
function initMap() {
new Map();
};
MoviesEntities db = new MoviesEntities();
更新:
public class MoviesController : Controller
{
MoviesEntities db = new MoviesEntities();
public ActionResult Index()
{
var movies = from m in db.Movies
where m.ReleaseDate > new DateTime(1984, 6, 1)
select m;
return View(movies.ToList());
}
}
可能是DB中的存储过程,但我在MSDN示例中也找不到它。
您可以通过更改来解决
AddToMovies
到
db.AddToMovies(newMovie)