comparison Demo/Silverlight/Client/MainPage.xaml.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 using System;
2 using System.Linq;
3 using System.Threading;
4 using System.Windows.Controls;
5 using BLToolkit.Data.Linq;
6
7 namespace Client
8 {
9 public partial class MainPage : UserControl
10 {
11 public class Data
12 {
13 public string Name;
14 public int Sum;
15 }
16
17 public MainPage()
18 {
19 InitializeComponent();
20
21 ThreadPool.QueueUserWorkItem(_ =>
22 {
23 try
24 {
25 using (var dm = new DataModel())
26 {
27 var q =
28 from c in dm.Categories
29 where !c.CategoryName.StartsWith("Con")
30 orderby c.CategoryName
31 select c.CategoryName;
32
33 (from t in dm.Categories
34 group t by t.CategoryName into g
35 select new Data
36 {
37 Name = g.Key,
38 Sum = g.Sum(a => a.CategoryID)
39 }).ToList();
40
41 var text = string.Join("\n", q.ToArray());
42
43 Dispatcher.BeginInvoke(() => OutputText.Text = text);
44
45 dm.BeginBatch();
46
47 dm.Categories.Delete(c => c.CategoryID == -99999);
48 dm.Categories.Delete(c => c.CategoryID == -999999);
49
50 dm.CommitBatch();
51 }
52 }
53 catch (Exception ex)
54 {
55 Dispatcher.BeginInvoke(() => OutputText.Text = ex.Message);
56 }
57
58 //new ServiceReference1.TestLinqWebServiceSoap();
59 });
60 }
61 }
62 }