-
Notifications
You must be signed in to change notification settings - Fork 527
Expand file tree
/
Copy pathLinqGeneralBaselineTests.TestQueryFlattening.xml
More file actions
180 lines (180 loc) · 7.17 KB
/
LinqGeneralBaselineTests.TestQueryFlattening.xml
File metadata and controls
180 lines (180 loc) · 7.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<Results>
<Result>
<Input>
<Description><![CDATA[array create]]></Description>
<Expression><![CDATA[query.Select(f => f.Int).Select(i => new [] {i})]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE [root["Int"]]
FROM root]]></SqlQuery>
</Output>
</Result>
<Result>
<Input>
<Description><![CDATA[unary operation]]></Description>
<Expression><![CDATA[query.Select(f => f.Int).Select(i => -i)]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE (- root["Int"])
FROM root]]></SqlQuery>
</Output>
</Result>
<Result>
<Input>
<Description><![CDATA[binary operation]]></Description>
<Expression><![CDATA[query.Select(f => f).Select(i => ((i.Int % 10) * i.Children.Count()))]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE ((root["Int"] % 10) * ARRAY_LENGTH(root["Children"]))
FROM root]]></SqlQuery>
</Output>
</Result>
<Result>
<Input>
<Description><![CDATA[literal]]></Description>
<Expression><![CDATA[query.Select(f => f.Int).Select(i => 0)]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE 0
FROM root]]></SqlQuery>
</Output>
</Result>
<Result>
<Input>
<Description><![CDATA[function call]]></Description>
<Expression><![CDATA[query.Select(f => f.Parents).Select(p => p.Count())]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE ARRAY_LENGTH(root["Parents"])
FROM root]]></SqlQuery>
</Output>
</Result>
<Result>
<Input>
<Description><![CDATA[object create]]></Description>
<Expression><![CDATA[query.Select(f => f.Parents).Select(p => new AnonymousType(parentCount = p.Count()))]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE {"parentCount": ARRAY_LENGTH(root["Parents"])}
FROM root]]></SqlQuery>
</Output>
</Result>
<Result>
<Input>
<Description><![CDATA[conditional]]></Description>
<Expression><![CDATA[query.Select(f => f.Children).Select(c => IIF((c.Count() > 0), "have kids", "no kids"))]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE ((ARRAY_LENGTH(root["Children"]) > 0) ? "have kids" : "no kids")
FROM root]]></SqlQuery>
</Output>
</Result>
<Result>
<Input>
<Description><![CDATA[property ref + indexer]]></Description>
<Expression><![CDATA[query.Select(f => f).Where(f => ((f.Children.Count() > 0) AndAlso (f.Children[0].Pets.Count() > 0))).Select(f => f.Children[0].Pets.get_Item(0).GivenName)]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE root["Children"][0]["Pets"][0]["GivenName"]
FROM root
WHERE ((ARRAY_LENGTH(root["Children"]) > 0) AND (ARRAY_LENGTH(root["Children"][0]["Pets"]) > 0))]]></SqlQuery>
</Output>
</Result>
<Result>
<Input>
<Description><![CDATA[array creation -> indexer]]></Description>
<Expression><![CDATA[query.Select(f => new [] {f.Int}).Select(array => array[0])]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE [root["Int"]][0]
FROM root]]></SqlQuery>
</Output>
</Result>
<Result>
<Input>
<Description><![CDATA[unary, indexer, property, function call -> function call]]></Description>
<Expression><![CDATA[query.Where(f => (f.Children.Count() > 0)).Select(f => -f.Children[0].Pets.Count()).Select(i => Abs(i))]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE ABS((- ARRAY_LENGTH(root["Children"][0]["Pets"])))
FROM root
WHERE (ARRAY_LENGTH(root["Children"]) > 0)]]></SqlQuery>
</Output>
</Result>
<Result>
<Input>
<Description><![CDATA[binary operation, function call -> conditional]]></Description>
<Expression><![CDATA[query.Select(i => ((i.Int % 10) * i.Children.Count())).Select(i => IIF((i > 0), new [] {i}, new [] {}))]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE ((((root["Int"] % 10) * ARRAY_LENGTH(root["Children"])) > 0) ? [((root["Int"] % 10) * ARRAY_LENGTH(root["Children"]))] : [])
FROM root]]></SqlQuery>
</Output>
</Result>
<Result>
<Input>
<Description><![CDATA[object creation -> conditional]]></Description>
<Expression><![CDATA[query.Select(f => new AnonymousType(parentCount = f.Parents.Count(), childrenCount = f.Children.Count())).Select(r => IIF((r.parentCount > 0), Floor((Convert(r.childrenCount, Double) / Convert(r.parentCount, Double))), 0))]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE (({"parentCount": ARRAY_LENGTH(root["Parents"]), "childrenCount": ARRAY_LENGTH(root["Children"])}["parentCount"] > 0) ? FLOOR(({"parentCount": ARRAY_LENGTH(root["Parents"]), "childrenCount": ARRAY_LENGTH(root["Children"])}["childrenCount"] / {"parentCount": ARRAY_LENGTH(root["Parents"]), "childrenCount": ARRAY_LENGTH(root["Children"])}["parentCount"])) : 0)
FROM root]]></SqlQuery>
</Output>
</Result>
<Result>
<Input>
<Description><![CDATA[indexer -> function call]]></Description>
<Expression><![CDATA[query.Select(f => f.Parents[0]).Select(p => Concat(p.FamilyName, p.GivenName))]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE CONCAT(root["Parents"][0]["FamilyName"], root["Parents"][0]["GivenName"])
FROM root]]></SqlQuery>
</Output>
</Result>
<Result>
<Input>
<Description><![CDATA[conditional -> object creation]]></Description>
<Expression><)).Select(p => new AnonymousType(parentCount = p.Count()))]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE {"parentCount": ARRAY_LENGTH(((ARRAY_LENGTH(root["Parents"]) > 0) ? root["Parents"] : []))}
FROM root]]></SqlQuery>
</Output>
</Result>
<Result>
<Input>
<Description><![CDATA[object creation -> conditional]]></Description>
<Expression><![CDATA[query.Select(f => new AnonymousType(children = f.Children)).Select(c => IIF((c.children.Count() > 0), c.children[0].GivenName, "no kids"))]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE ((ARRAY_LENGTH({"children": root["Children"]}["children"]) > 0) ? {"children": root["Children"]}["children"][0]["GivenName"] : "no kids")
FROM root]]></SqlQuery>
</Output>
</Result>
<Result>
<Input>
<Description><![CDATA[object creation -> conditional]]></Description>
<Expression><![CDATA[query.Select(f => new AnonymousType(family = f, children = f.Children.Count())).Select(f => IIF(((f.children > 0) AndAlso (f.family.Children[0].Pets.Count() > 0)), f.family.Children[0].Pets.get_Item(0).GivenName, "no kids"))]]></Expression>
</Input>
<Output>
<SqlQuery><![CDATA[
SELECT VALUE ((({"family": root, "children": ARRAY_LENGTH(root["Children"])}["children"] > 0) AND (ARRAY_LENGTH({"family": root, "children": ARRAY_LENGTH(root["Children"])}["family"]["Children"][0]["Pets"]) > 0)) ? {"family": root, "children": ARRAY_LENGTH(root["Children"])}["family"]["Children"][0]["Pets"][0]["GivenName"] : "no kids")
FROM root]]></SqlQuery>
</Output>
</Result>
</Results>