Dynamic Linq Select -


i having trouble wrapping head around dynamic linq select. have read scott gu's blog , each of suggested posts still cannot little brain understand. need query entity object passing in variable column name. assume entity (table) containing 3 columns named: mon, tue & wed. these contain data each record. not know column hit @ compile time need pass column name query. how can accomplish either using dlink or directly using expression trees?

don't need dynamic linq that...

var columniwant="mon"; // or "tue" or "wed" var query=db.stuff here;  iqueryable<string> result; switch(columniwant) {   case "mon": result=query.select(q=>q.mon); break;   case "tue": result=query.select(q=>q.tue); break;   case "wed": result=query.select(q=>q.wed); break; } 

that said, think work:

var result=db.stuff here.select(columniwant); 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -