Assume that the current odata service address is
Http: // localhost: 9527/odataservice. SVC
The provided services are as follows (Wagerinformations)
Code
<? XML version = "1.0" encoding = "UTF-8" standalone = "yes" ?>
< Service XML: Base = "Http: // localhost: 9527/odataservice. svc /" Xmlns: Atom = "Http://www.w3.org/2005/Atom" Xmlns: app = "Http://www.w3.org/2007/app" Xmlns = "Http://www.w3.org/2007/app" >
< Workspace >
< Atom: Title > Default </ Atom: Title >
< Collection Href = "Wagerinformations" >
< Atom: Title > Wagerinformations </ Atom: Title >
</ Collection >
</ Workspace >
</ Service >
1. Basic Query
1) list all wagerinformations
Http: // localhost: 9527/odataservice. svc/wagerinformations
2) query by primary key
Http: // localhost: 9527/odataservice. svc/wagerinformations (1)
PS: Used in. netDataservicekeyattributePrimary Key ID
3) Obtain a member of an object
Http: // localhost: 9527/odataservice. svc/wagerinformations (1)/eventname
Obtain the eventname attribute of wagerinformations whose primary key is 1.
4) if this property has another property, so do it.
Http: // localhost: 9527/odataservice. svc/wagerinformations (1)/event/eventdatetime
In addition, do not try to obtain some attributes of the original type--# For example, return the Length attribute of string
5) $ Value Scheme 3: a member of the returned object uses the XML data format. In fact, we often don't need so many labels, just want to get the return value.
Use URL http: // localhost: 9527/odataservice. svc/wagerinformations (1)/eventname/$ Value
Data in solution 3<?XML version = "1.0" encoding = "UTF-8" standalone = "yes"?> <EventnameXmlns="Http://schemas.microsoft.com/ado/2007/08/dataservices">Test 1</Eventname>
Test 1 of solution 5
6) $ filter condition expression
The expression for querying if eventname is equal to "Test 1" is as follows:
Http: // localhost: 9527/odataservice. svc/wagerinformations? $ Filter = eventname EQ 'test 1'
Query time:
Http: // localhost: 9527/odataservice. svc/wagerinformations? $ Filter = eventdatetime EQ datetime '2017-12-21t10: 10: 8080'
Combined Query expression: And Operation
Http: // localhost: 9527/odataservice. svc/wagerinformations? $ Filter = (eventdatetime EQ datetime '2017-12-21t10: 10: 100') and (businessunitcode EQ '2 ')
The following is a list of operators.
Operator |
Description |
C # equivalent |
EQ |
EQUals |
= |
Ne |
NOTEQual |
! = |
GT |
GReaterTHan |
> |
Ge |
GReater than orEQual |
> = |
Lt |
LESSTHan |
< |
Le |
LEss than orEQual |
<= |
And |
And |
&& |
Or |
Or |
| |
() |
Grouping |
() |
Address: http://blogs.msdn.com/ B /alexj/archive/2009/11/18/tip-44-how-to-navigate-an-odata-compliant-service.aspx