简体   繁体   中英

Asp.net mvc sql query as parameter to controller action method

I am trying to send a query like below from UI to controller.

name='abc' and title='def'

I am trying to use lambda expression on controller to filter this query. But I am struggling hard to pass ui query to controller and make it as lambda expression.

Could you please throw some idea with example where i can pass sql query(string) as parameter and use it in controller action method as lambda expression. Any link or logic should be fine for me to try further.

 [HttpGet]
 public virtual ActionResult QueriedProjects(string builtQuery)
 {
     var Helpera = new Helpera(true);

     var myProjectDetails = Helpera.myProjectDetails (null);
     var myProjectDetails = new myProjectDetails () 
     { GetMyProjectDetails = myProjectDetails  };
     return View(myProjectDeails)
 }

UI

on button click I am generating a query as string with entered values in query builder

Generated String: name='abc' and title= 'def'

If you pass values like this:

Contoller/QueriedProjects?name=abc&title=def

You need to have 2 parameters in your controller method like:

public virtual ActionResult QueriedProjects(string name, string title)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM