dlr bug
[mcs.git] / tests / gtest-linq-10.cs
blob7b49ea0055d121b78e835cb4cd1d74fc2b4b9fc4
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
7 class DataA
9 public int Key;
10 public string Text;
13 class DataB
15 public int Key;
16 public string Value;
19 class GroupJoin
21 public static int Main ()
23 DataA[] d1 = new DataA[] { new DataA () { Key = 1, Text = "Foo" }};
24 DataB[] d2 = new DataB[] { new DataB () { Key = 2, Value = "Second" }};
26 var e = from a in d1
27 join b in d2 on a.Key equals b.Key into ab
28 from x in ab.DefaultIfEmpty ()
29 select new { a = x == default (DataB) ? "<empty>" : x.Value, b = a.Text };
31 var res = e.ToList ();
32 if (res.Count != 1)
33 return 1;
35 if (res [0].a != "<empty>")
36 return 2;
38 if (res [0].b != "Foo")
39 return 3;
41 // Explicitly typed
42 e = from a in d1
43 join DataB b in d2 on a.Key equals b.Key into ab
44 from x in ab.DefaultIfEmpty ()
45 select new { a = x == default (DataB) ? "<empty>" : x.Value, b = a.Text };
47 foreach (var o in e)
48 Console.WriteLine (o);
50 res = e.ToList ();
51 if (res.Count != 1)
52 return 10;
54 if (res [0].a != "<empty>")
55 return 11;
57 if (res [0].b != "Foo")
58 return 12;
60 // FIXME: Used same name
61 //var e2 = from a in d1
62 // join a in d2 on a.Key equals a.Key into ab
63 // select a;
65 Console.WriteLine ("OK");
66 return 0;