Using Entity Framework
Model
[Bind(Exclude="GenreId")]
public class Genre
{
[ScaffoldColumn(false)]
public int GenreId { get; set; }
public string GenreName { get; set; }
public string Description { get; set; }
public Boolean Status { get; set; }
}
Entity Class
public class MVCBookStoreEntities:DbContext
{
public MVCBookStoreEntities()
: base("name=ApplicationServices")
{ }
public DbSet genres { get; set; }
}
Global.asax
on Application_Start add this
Database.SetInitializer(new DropCreateDatabaseIfModelChanges());
Controller
MVCBookStoreEntities db = new MVCBookStoreEntities();
public ActionResult Index()
{
List gen =new List();
gen=db.genres.ToList();
var model=from g in gen
orderby g.GenreId descending
where g.Status==true
select g;
return View(model);
}
[Bind(Exclude="GenreId")]
public class Genre
{
[ScaffoldColumn(false)]
public int GenreId { get; set; }
public string GenreName { get; set; }
public string Description { get; set; }
public Boolean Status { get; set; }
}
Entity Class
public class MVCBookStoreEntities:DbContext
{
public MVCBookStoreEntities()
: base("name=ApplicationServices")
{ }
public DbSet
}
Global.asax
on Application_Start add this
Database.SetInitializer(new DropCreateDatabaseIfModelChanges
Controller
MVCBookStoreEntities db = new MVCBookStoreEntities();
public ActionResult Index()
{
List
gen=db.genres.ToList();
var model=from g in gen
orderby g.GenreId descending
where g.Status==true
select g;
return View(model);
}
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment