Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Customize Query
posted

Is there anyway to customize the Query expression tree before it's executed against the IQueryable data source in the Controller?

Im assuming this is currently done inside the ComboDataSourceAction attribute, and it uses the values from the QueryString on the filter parameter.

I need to customize the query because I want to leverage LinqToEntities against multiple fields in a database table.

Thanks.

Jean

Parents
No Data
Reply
  • 6279
    posted

    Hi Jean,

    Yes, you are are correct that the data transformations on the source data (IQueryable) are done by the logic behind the ComboDataSourceAction attribute. Thus, if you wish to alter the IQueryable before these transformations take place, simply do the necessary changes inside the controller action that's marked with this attribute.

    Allow me to demonstrate using the sample controller action from the http://es.infragistics.com/products/jquery/sample/combo-box/auto-suggest-and-filtering sample:

    [ComboDataSourceAction]
            [ActionName("filtering-data")]
            public ActionResult ComboGetData()
            {
                var ds = this.DataRepository.GetDataContext().Products;
                // TODO alter the ds as you wish - the ComboDataSourceAction attribute will transform it further afterwards.
    
                return View(ds);
            }
    

    If you had something else in mind, please provide us with a sample of the alteration that you wish to carry out so we can try and help you out.
    Thanks! 

    PS: The ComboDataSourceAction attribute is actually an ActionFilter so these articles may aid you in understanding it:
    Filtering in ASP.NET MVC
    Action Filtering in ASP.NET MVC Applications

Children