public ActionResult IndexPerTypeId(int id, string type)
{
Expression<Func<Transaction, bool>> lamda;
switch (type)
{
case "Book": lamda = t => t.BookId == id; break;
case "Category": lamda = t => t.CategoryId == id; break;
case "Payee": lamda = t => t.PayeeId == id; break;
case "Project": lamda = t => t.ProjectId == id; break;
default: lamda = t => true == true; break;
}
var transcationset = db.TranscationSet
.Where(lamda)
.OrderByDescending(t => t.Date)
.Include(t => t.Category).Include(t => t.Payee)
.Include(t => t.Project).Include(t => t.Book);
return PartialView("Index", transcationset.ToList());
}
沒有留言:
張貼留言