I have a query that gives data like the following:
event | Yoga | Date sent. 400 1/1/12 open | 200 | Click 1/1/12. 50 | 1/1/12 sent. 300 Open 1/8/12. 150 | Click 1/8/12. 30 | SQL query: select event, zodiac (thecount), event from group, send_open_click_counts, order sorted by rundet, to render graph To send these values to the Visualization API, I need to organize such values:
['date', '' 1/1/12 '' , '400', '200', '50'] ['1/8/12', '300', '150', '30'] I really like this stuff Not familiar with, but for me the spindle from the date
Here is a Linux query that I used to use in my original SQL
var dbLinqObj = db.SEND_OPEN_CLICK_COUNTS group RR in ARIUNT RRDNDATE} to new {EVENT = G} . KEENEN, THICATT = G. SUM (R = & gt; RHECACT), RUNDTE = G.K.A. DbLinqObj = dbLinqObj.OrderBy (R => R. Rundt); ==== Edit ==== Found solutions =====
After digging in this and after receiving some suggestions from comments, I Elegant solution using found LINQ.
Here is the LINQ that will deliver the result properly so that it can be easily converted to a JSON string.
var query = q to Db.SEND_OPEN_CLICK_COUNTS in q q.RUNDATE by group q new {date = g.Key, send = g.Where (x => x.EVENT = = "Sent"). Yoga (x => x.THECOUNT), open = g. Where (x => x.EVENT == "opened"). Sam (x => x.THECOUNT), click = g. Where (x = & gt; x.EVENT == "clicked") .Sum (x => x.THECOUNT)};
The linq smoke used by you is usually done, how it is done Array that you can try to use the Composite linq method to create JSON. For example:
var dbLinqObj = db by r new {r.EVENT, r.RUNDATE} SEND_OPEN_CLICK_COUNTS Group R new {EVENT = G. KEENETNT, THECOUNT = G. Choose SUM (R = & gt; RHECACT), RUNDATE = g.Key.RUNDATE}; Var dbLinqObjJSON = dbLinqObj.OrderBy (r = & gt; r.RUNDATE). Overgrazed ((json, x) => gt; json + "['" + x.RUNDATE + ","' + + x.THECOUNT + ' ',' ... ... + "]"; Note that overall does not use stringbirders, so there will be a performance hit for larger views There is currently a problem with your post code because you are using StringBuilder instead of string to create your JSON. Every time you press + operator uses string on .NET run The need to create a new string by the author. If you want to make it as fast as possible, a StringBuilder : var dbLinqObjJSON = DbLinqObj.OrderBy (r = & gt; r.RUNDATE). Forgotten (new string builder ("['Date' ',' Sent ',' opened '' ''],"), (json, x) = & Gt; json.append ("['" + x.RUNDATE + "', '" + x.THECOUNT + "', '" + ... + "],"), (JSN) => Jason Toastring ());
Comments
Post a Comment