-
Notifications
You must be signed in to change notification settings - Fork 14
/
Example Queries.odata
115 lines (69 loc) · 4.33 KB
/
Example Queries.odata
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
Service Metadata
==================================================================
https://localhost:8086/odata
https://localhost:8086/odata/$metadata
https://localhost:8086/odata/$metadata?$format=json
FAILS, returns XML. "Accept" header should work but also fails!
Entity Sets
==================================================================
https://localhost:8086/odata/Customers
https://localhost:8086/odata/Customers?$select=CustomerNumber,Name
https://localhost:8086/odata/Customers/$count
https://localhost:8086/odata/Customers?$filter=State eq 'CA'
https://localhost:8086/odata/Customers?$filter=not State eq 'CA'
FAILS - returns exception to browser
https://localhost:8086/odata/Customers?$filter= CreditLimit gt 5000
https://localhost:8086/odata/Customers?$filter=State eq 'CA' and CreditLimit gt 5000
https://localhost:8086/odata/Customers?$filter=State eq 'NV'&$select=CustomerNumber,Name
https://localhost:8086/odata/Customers/$count?$filter=State eq 'NV'
https://localhost:8086/odata/Customers?$filter=State in ('OR', 'WA')
https://localhost:8086/odata/Customers?$top=5
https://localhost:8086/odata/Customers?$top=5&$skip=5
https://localhost:8086/odata/Items?$filter=not endswith(LatinName,'costata')
FAILS - returns full collection
Individual Entities By Primary Key
==================================================================
https://localhost:8086/odata/Customers(1)
https://localhost:8086/odata/Customers(1)/Name
https://localhost:8086/odata/Customers(1)/Name/$value
https://localhost:8086/odata/Customers/1
https://localhost:8086/odata/Customers/1/Name
https://localhost:8086/odata/Customers/1/Name/$value
Individual Entities By Alternate key
==================================================================
https://localhost:8086/odata/Items(VendorNumber=42)
https://localhost:8086/odata/Items(VendorNumber=42)/$count
FAILS - 404
https://localhost:8086/odata/Items(FlowerColor='white')
https://localhost:8086/odata/Items(Size=3)
https://localhost:8086/odata/Items(Size=3)?$filter=Shape eq 'bush' and FlowerColor eq 'purple'&$select=ItemNumber,CommonName
https://localhost:8086/odata/Items(CommonName='Hedge Maple')
Relations
==================================================================
https://localhost:8086/odata/Customers(8)?$expand=REL_CustomerOrders
https://localhost:8086/odata/Customers(1)?$expand=REL_CustomerOrders
Customer 1 has no orders
https://localhost:8086/odata/Customers(8)?$expand=REL_CustomerOrders
Customer 8 has 3 orders
https://localhost:8086/odata/Customers(8)/REL_CustomerOrders
FAILS - 404
https://localhost:8086/odata/Customers(8)?$expand=REL_CustomerOrders($expand=REL_OrderItems($expand=REL_ItemOrdered($expand=REL_VendorNumber)))
FAILS with "The request includes a $expand path which is too deep"
https://localhost:8086/odata/Customers(8)?$expand=REL_CustomerOrders($filter=OrderNumber eq 7)
https://localhost:8086/odata/Customers(8)?$expand=REL_CustomerOrders&$filter=REL_Orders/OrderNumber eq 7
FAILS - correct syntax ?
The parent value for a property access of a property 'OrderNumber' is not a single value.
Property access can only be applied to a single value.
Collections with Multiple Key Segments
==================================================================
https://localhost:8086/odata/OrderItems
https://localhost:8086/odata/OrderItems?$filter=OrderNumber eq 3
https://localhost:8086/odata/OrderItems(OrderNumber=3,ItemNumber=1)
https://localhost:8086/odata/OrderItems/3/1
FAILS - 404
NEW
https://localhost:8086/odata/Customers(8)?$expand=REL_CustomerOrders($expand=REL_OrderItems($expand=REL_ItemOrdered))&$select=CustomerNumber,Name
https://localhost:8086/odata/Customers(8)?$expand=REL_CustomerOrders($select=PlacedBy;$expand=REL_OrderItems($expand=REL_ItemOrdered))
https://localhost:8086/odata/Customers(8)?$expand=REL_CustomerOrders($expand=REL_OrderItems($expand=REL_ItemOrdered($expand=REL_VendorNumber)))
https://localhost:8086/odata/Customers(8)?$expand=REL_CustomerOrders($select=OrderNumber,DateOrdered;$expand=REL_OrderItems($select=ItemNumber,QuantityOrdered;$expand=REL_ItemOrdered))&$select=CustomerNumber,Name
https://localhost:8086/odata/Customers(8)?$select=CustomerNumber,Name&$expand=REL_CustomerOrders($select=OrderNumber,DateOrdered;$expand=REL_OrderItems($select=ItemNumber,ItemOrdered,QuantityOrdered,UnitPrice;$expand=REL_ItemOrdered($select=CommonName,Size)))