/* request the number of championships for each city in database for a client query */ public void getCitiesChampionshipsNum(bool delay) { ICallBack channel = OperationContext.Current.GetCallbackChannel <ICallBack>(); if (delay) { ManualResetEvent delayEvent = new ManualResetEvent(false); ThreadPool.QueueUserWorkItem(new WaitCallback((_) => { sleep(); delayEvent.Set(); })); delayEvent.WaitOne(); } using (var db = new TTTDataClassesDataContext()) { var x = db.Championships.GroupBy(c => c.City); CityChampionships[] citiesChmps = new CityChampionships[x.Count()]; int i = 0; foreach (var cc in x) { citiesChmps[i] = new CityChampionships(); citiesChmps[i].City = cc.Key; citiesChmps[i++].NumberOfChampionships = cc.Count(); } channel.sendCitiesChampionshipsNum(citiesChmps); } }
public void setCitiesChampionshipsNum(CityChampionships[] citiesChmps) { this.queryObjects = citiesChmps; string[] titles = { "City", "NumberOfChampionships" }; string[] types = { "char", "int" }; bool[] readOnly = { true, true }; bool[] nullable = { false, false }; ctrl = new QueryControl(queryObjects, titles, types, readOnly, nullable); tableElementHost.Child = ctrl; ctrl.setSelectionType(cbDelType.SelectedIndex == 1); }
/* request the number of championships for each city in database for a client query */ public void getCitiesChampionshipsNum(bool delay) { ICallBack channel = OperationContext.Current.GetCallbackChannel<ICallBack>(); if (delay) { ManualResetEvent delayEvent = new ManualResetEvent(false); ThreadPool.QueueUserWorkItem(new WaitCallback((_) => { sleep(); delayEvent.Set(); })); delayEvent.WaitOne(); } using (var db = new TTTDataClassesDataContext()) { var x = db.Championships.GroupBy(c => c.City); CityChampionships[] citiesChmps = new CityChampionships[x.Count()]; int i = 0; foreach (var cc in x) { citiesChmps[i] = new CityChampionships(); citiesChmps[i].City = cc.Key; citiesChmps[i++].NumberOfChampionships = cc.Count(); } channel.sendCitiesChampionshipsNum(citiesChmps); } }
public void sendCitiesChampionshipsNum(CityChampionships[] citiesChmps) { if (mainForm.queriesForm != null) mainForm.queriesForm.setCitiesChampionshipsNum(citiesChmps); }