基本介紹
- 中文名:開放數據協定
- 外文名:Open Data Protocol (OData)
- 標準組織:OASIS
- 最新版本:4.0
發展簡史
協定發起
協定在微軟內部的演進
協定成為OASIS標準
協定組成
核心協定
URL規範
- URL的組成部分
- 服務的根URL
- 資源路徑
- 查詢語句
通用格式定義語言(CSDL)
- CSDL的命名空間
- 實體模型的封裝
- 實體模型的普通特性
- 具體的XML元素和屬性介紹
擴展的巴科斯範式(ABNF)
- 資源路徑
- 查詢語句
- 上下文URL(context URL)
- 表達式
- OData函式參數的JSON格式
- 命名與標識符(identifiers)
- 數據字面值(literal data values)
- 標頭值(header values)
- 標點符號
協定拓展
JSON格式
Atom格式
辭彙表(vocabulary)
數據聚合(data aggregation)拓展
- 查詢聚合數據的語義和表現形式
- 查詢聚合數據的結果格式
- 標記何種數據可以被聚合,如何聚合的辭彙(vocabulary term)
協定請求(request)示例
數據請求
操作符 | 描述 | 例子 |
eq | 等於 | Address/City eq '上海' |
ne | 不等於 | Address/City ne '上海' |
gt | 大於 | Price gt 20 |
ge | 大於等於 | Price ge 10 |
lt | 小於 | Price lt 20 |
le | 小於等於 | Price le 100 |
has | 有標誌(flags) | Style has Sales.Color'黃色' |
操作符 | 描述 | 例子 |
and | 邏輯與 | Price le 200 and Price gt 3.5 |
or | 邏輯或 | Price le 3.5 or Price gt 200 |
not | 邏輯非 | not endwith(Description, '牛奶') |
操作符 | 描述 | 例子 |
add | 加 | Price add 5 gt 10 |
sub | 減 | Price sub 5 gt 10 |
mul | 乘 | Price mul 2 gt 2000 |
div | 除 | Price div 2 gt 4 |
mod | 取模 | Price mod 2 eq 0 |
操作符 | 描述 | 例子 |
( ) | 優先權分組 | (Price sub 5) gt 10 |
函式 | 例子 |
contains | contains(CompanyName, '公司') |
endswith | endswith(CompanyName, '公司') |
startswith | startswith(CompanyName, '中國') |
length | length(CompanyName) eq 6 |
indexof | indexof(CompanyName, '國') eq 1 |
substring | substring(CompanyName, 1) eq '國開放數據有限公司' |
tolower | tolower(EnglishName) eq 'ABC' |
toupper | toupper(EnglishName) eq 'abc' |
trim | trim(FullName) eq 'Russell Whyte' |
concat | concat(concat(City, ','), Country) eq '中國,上海' |
函式 | 例子 |
year | year(BirthDate) eq 0 |
month | month(BirthDate) eq 12 |
day | day(StartTime) eq 8 |
hour | hour(StartTime) eq 1 |
minute | minute(StartTime) eq 0 |
second | second(StartTime) eq 0 |
fractionalseconds | fractionalseconds(StartTime) eq 0 |
date | date(StartTime) ne date(EndTime) |
time | time(StartTime) le StartOfDay |
totaloffsetminutes | totaloffsetminutes(StartTime) eq 60 |
now | StartTime ge now() |
mindatetime | StartTime eq mindatetime() |
maxdatetime | EndTime eq maxdatetime() |
函式 | 例子 |
round | round(Freight) eq 32 |
floor | floor(Freight) eq 32 |
ceiling | ceiling(Freight) eq 33 |
函式 | 例子 |
cast | cast(ShipCountry, Edm.String) |
isof | isof(NorthwindModel.Order) |
isof | isof(ShipCountry, Edm.String) |
函式 | 例子 |
geo.distance | geo.distance(CurrentPosition, TargetPosition) |
geo.length | geo.length(DirectRoute) |
geo.intersects | geo.intersects(Position, TargetArea) |