Knockout Fonksiyoları ve Kullanımı

Operator Description Example
Logical Operators
Eq Equal /Suppliers?$filter=Address/City eq ‘Redmond’
Ne Not equal /Suppliers?$filter=Address/City ne ‘London’
Gt Greater than /Products?$filter=Price gt 20
Ge Greater than or equal /Products?$filter=Price ge 10
Lt Less than /Products?$filter=Price lt 20
Le Less than or equal /Products?$filter=Price le 100
And Logical and /Products?$filter=Price le 200 and Price gt 3.5
Or Logical or /Products?$filter=Price le 3.5 or Price gt 200
Not Logical negation /Products?$filter=not endswith(Description,’milk’)
Arithmetic Operators
Add Addition /Products?$filter=Price add 5 gt 10
Sub Subtraction /Products?$filter=Price sub 5 gt 10
Mul Multiplication /Products?$filter=Price mul 2 gt 2000
Div Division /Products?$filter=Price div 2 gt 4
Mod Modulo /Products?$filter=Price mod 2 eq 0
Grouping Operators
( ) Precedence grouping /Products?$filter=(Price sub 5) gt 10

 

Function Example
String Functions
bool substringof(string po, string p1) http://services.odata.org/Northwind/Northwind.svc/Customers?$filter=substringof(‘Alfreds’, CompanyName) eq true
bool endswith(string p0, string p1) http://services.odata.org/Northwind/Northwind.svc/Customers?$filter=endswith(CompanyName, ‘Futterkiste’) eq true
bool startswith(string p0, string p1) http://services.odata.org/Northwind/Northwind.svc/Customers?$filter=startswith(CompanyName, ‘Alfr’) eq true
int length(string p0) http://services.odata.org/Northwind/Northwind.svc/Customers?$filter=length(CompanyName) eq 19
int indexof(string p0, string p1) http://services.odata.org/Northwind/Northwind.svc/Customers?$filter=indexof(CompanyName, ‘lfreds’) eq 1
string replace(string p0, string find, string replace) http://services.odata.org/Northwind/Northwind.svc/Customers?$filter=replace(CompanyName, ‘ ‘, ”) eq ‘AlfredsFutterkiste’
string substring(string p0, int pos) http://services.odata.org/Northwind/Northwind.svc/Customers?$filter=substring(CompanyName, 1) eq ‘lfreds Futterkiste’
string substring(string p0, int pos, int length) http://services.odata.org/Northwind/Northwind.svc/Customers?$filter=substring(CompanyName, 1, 2) eq ‘lf’
string tolower(string p0) http://services.odata.org/Northwind/Northwind.svc/Customers?$filter=tolower(CompanyName) eq ‘alfreds futterkiste’
string toupper(string p0) http://services.odata.org/Northwind/Northwind.svc/Customers?$filter=toupper(CompanyName) eq ‘ALFREDS FUTTERKISTE’
string trim(string p0) http://services.odata.org/Northwind/Northwind.svc/Customers?$filter=trim(CompanyName) eq ‘Alfreds Futterkiste’
string concat(string p0, string p1) http://services.odata.org/Northwind/Northwind.svc/Customers?$filter=concat(concat(City, ‘, ‘), Country) eq ‘Berlin, Germany’
Date Functions
int day(DateTime p0) http://services.odata.org/Northwind/Northwind.svc/Employees?$filter=day(BirthDate) eq 8
int hour(DateTime p0) http://services.odata.org/Northwind/Northwind.svc/Employees?$filter=hour(BirthDate) eq 0
int minute(DateTime p0) http://services.odata.org/Northwind/Northwind.svc/Employees?$filter=minute(BirthDate) eq 0
int month(DateTime p0) http://services.odata.org/Northwind/Northwind.svc/Employees?$filter=month(BirthDate) eq 12
int second(DateTime p0) http://services.odata.org/Northwind/Northwind.svc/Employees?$filter=second(BirthDate) eq 0
int year(DateTime p0) http://services.odata.org/Northwind/Northwind.svc/Employees?$filter=year(BirthDate) eq 1948
Math Functions
double round(double p0) http://services.odata.org/Northwind/Northwind.svc/Orders?$filter=round(Freight) eq 32
decimal round(decimal p0) http://services.odata.org/Northwind/Northwind.svc/Orders?$filter=round(Freight) eq 32
double floor(double p0) http://services.odata.org/Northwind/Northwind.svc/Orders?$filter=filter=round(Freight) eq 32
decimal floor(decimal p0) http://services.odata.org/Northwind/Northwind.svc/Orders?$filter=floor(Freight) eq 32
double ceiling(double p0) http://services.odata.org/Northwind/Northwind.svc/Orders?$filter=ceiling(Freight) eq 33
decimal ceiling(decimal p0) http://services.odata.org/Northwind/Northwind.svc/Orders?$filter=floor(Freight) eq 33
Type Functions
bool IsOf(type p0) http://services.odata.org/Northwind/Northwind.svc/Orders?$filter=isof(‘NorthwindModel.Order’)
bool IsOf(expression p0, type p1) http://services.odata.org/Northwind/Northwind.svc/Orders?$filter=isof(ShipCountry, ‘Edm.String’)

Bir Cevap Yazın

Aşağıya bilgilerinizi girin veya oturum açmak için bir simgeye tıklayın:

WordPress.com Logosu

WordPress.com hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap /  Değiştir )

Google fotoğrafı

Google hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap /  Değiştir )

Twitter resmi

Twitter hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap /  Değiştir )

Facebook fotoğrafı

Facebook hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap /  Değiştir )

Connecting to %s