c# - Dynamic Lambda Expressions -
i have front-end user can enter build string using buttons insert operators / operands , items want filter.
the purpose of function filter down list, used calculate quantity depending on number of items can take.
this string passed controller need use string query database using entity framework. have been looking @ dynamic lambda , linq solve not able need, when comes grouping of elements.
typically string might follows
(( mod1 = 1 ) or ( mod2 = 1 ) or ( mod3 = 1) , modhigh = 1)
i open change solution if there better way of doing so, had in mind following, more user friendly. again modelling in controller take doing, i'm not sure begin at.
intuitive interface composing boolean logic
edit
currently working following, based upon tutorial here
/// <summary> /// allows live updating of view show stores /// going effected rule. /// </summary> /// <param name="filterstring">customisable query view</param> /// <returns>json object - collection of stores</returns> public jsonresult getfilteredstores(string filterstring = "") { int customerid = (int)system.web.httpcontext.current.session["customerid"]; var query = spa in storeprofilelogic.getby(x => x.active && x.store.customerid == customerid) .where(filterstring) .orderby(x => x.storeid) select spa.storeid; return json(query, jsonrequestbehavior.allowget); }
Comments
Post a Comment