日期:2014-05-17 浏览次数:20470 次
using System;
using System.Data.Entity;
namespace MvcMovie.Models
{
public class Movie
{
public int ID { get; set; }
public string Title { get; set; }
public DateTime ReleaseDate { get; set; }
public string Genre { get; set; }
public decimal Price { get; set; }
}
public class MovieDBContext : DbContext
{
public DbSet<Movie> Movies { get; set; }
}
}
using MvcMovie.Models;
using System.Linq;
using System;
using System.Web.Mvc;
namespace MvcMovie.Controllers
{
public class MoviesController : Controller
{
MovieDBContext db = new MovieDBContext();
public ActionResult Index()
{
var movies=from m in db.Movies
where m.ReleaseDate>new DateTime(1984,6,1)
select m;
return View(movies.ToList());
}
}
}
@model IEnumerable<MvcMovie.Models.Movie>
@{
ViewBag.Title = "电影清单";
}
<h2>我的电影清单</h2>
<p>
@Html.ActionLink("追加", "Create")
</p>
<table>
<tr>
<th></th>
<th>
电影名称
</th>
<th>
发行日期
</th>
<th>
&nb