Skip to content

Dynamic query in mvc 5

jaydeep shah

Asked Oct 7, 2015, 4:25 AM EDT2 answers
Share
LinkedInX
C#
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());
        }

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    To pass that dynamic value as the argument to the ActionResult.
    0
  • 1 short reply
    • 0
      but how ??
      0