c# - Dynamic query generation -


i'm trying build dynamic query in c# entity framework. end goal allow user build own custom queries/reports in app. getting information angular , typescript, , have matching entities on both sides of app (both frontend , backend). goal here build sql query string can later execute directly on database. not concerned validation, time being, malformed queries valid results (i tackle hurdle later - 1 step @ time). entity follows:

 public class adhocline     {         //the table selecting column         [jsonproperty(propertyname = "table")]         public string table;         //the column user wants appear in report         [jsonproperty(propertyname = "column")]         public string column;         //any filter criteria (e.g. 'equals abcd', 'abcd')         [jsonproperty(propertyname = "usercriteria")]         public string usercriteria;         //the operator being used (e.g. 'equals abcd', 'equals'         [jsonproperty(propertyname = "op")]         public string op;         //if joining column, table joining         [jsonproperty(propertyname = "jointable")]         public string jointable;         //if joining column, column joining         [jsonproperty(propertyname = "joincolumn")]         public string joincolumn;         //since entity meant delivered in array, array index         [jsonproperty(propertyname = "index")]         public int index;         //this column our current table joining on         [jsonproperty(propertyname = "joinwith")]         public string joinwith;     } 

is there i'm missing in entity seems glaring?

upon reviewing related questions, use case may prove helpful. want select projectname (a string) table project , want include column description parent, programelement (where project has guid pointing programelement in question, called programelementid). result should following:

 select t1.projectname, t2.description project t1, programelement t2 <additional clause information belongs here> 

thanks in advance!

i've implemented bit more elaborate sql server side , first advice don't

but if must...

the obvious omission way of specifying join type

select t1.projectname, t2.description  project t1 join programelement t2  on t2.joincolumn = t1.joinwith <additional clause information belongs here> 

or

select t1.projectname, t2.description  project t1 left join programelement t2  on t2.joincolumn = t1.joinwith <additional clause information belongs here> 

also not make more sense have array of columns include opposed column property. they're going ask multiple columns may ready.

for matter should have array of columns second table

but looks need kick against specifications


Comments