jaydeep shah

jaydeep shah

  • NA
  • 44
  • 4k

dynamic query in mvc 5

Oct 7 2015 8:25 AM
public ActionResult ifcondi(DirectItem di)
{
string getDirectId = HttpUtility.HtmlEncode(di.Id);
var data1 = (from c in db.RowItems
join a in db.categories on c.CategoryItemId equals a.category_id
join d in db.DirectItems on c.DirectItemId equals d.Id
 
// here plazma 60 is static ..i have many button plazma 60 ,, plazma 90 ,and so on  
where d.ItemName == "plazma 60"    //insted of static item wht i have to add to make dynamik query
select new { c, a, d }).GroupBy(x => x.a.category_name).Select(y => new tempdata
{
CatagoryName = y.Key,
lists = y.Select(p => new a
{
name = p.c.ItemName
}).ToList()
}).ToList();
return View(data1.ToList());
}
 

Answers (2)