ADO.NET Data Services - $filter functions
Maybe I am too lazy or not efficient enough searching the Internet but It is hard to find a list of all the keywords available when interrogating an ADO.NET Data Service (service).
Therefore, I thought it could be faster to do a bit of Reflection (thanks to Reflector) against the System.Data.Services.dll in the System.Data.Services.Parsing namespace from the .NET Framework 3.5 Service pack1.
There are two types of operators – arithmetic and logical
1. Logical Operators
And = and
Or = or
Ascending = asc
Descending = desc
Equal = eq
Not Equal = ne
True = true
False = false
Greater Than = gt
Greater Than Or Equal = ge
Less Than = lt
Less Than Or Equal = le
Not = not
Null = null
2. Arithmetic Operators
Addition = add
Subtraction = sub
Divide = div
Multiply = mul
Modulo = mod
Aside from the list of operators, the filter parameter also has 4 categories of functions: String, Date, Math and Type.
1. String functions
Ends With = endswith(string)
Index Of = indexof(string)
Replace = replace(string, string)
Starts With = startswith(string)
To Lower = tolower(string)
To Upper = toupper(string)
Trim = trim(string)
Sub String = substring(int), substring(int, int)
Sub String Of = substringof(string, string)
Concatenation = concat(string, string)
Length = length(string)
2. Date functions
Year = year(datetime)
Month = month(datetime)
Day = day(datetime)
Hour = hour(datetime)
Minute = minute(datetime)
Second = second(datetime)
3. Math function
Round = round(double), round(decimal)
Floor = floor(double), floor(decimal)
Ceiling = ceiling(double), ceiling(decimal)
4. Type functions
Is Of = isof(type)
Cast = cast(type)
(Update – you can also have a list from Marcelo’s Weblog http://blogs.msdn.com/marcelolr/archive/2008/01/15/arithmetic-and-built-in-functions-for-filter.aspx – but this one seems to be outdated. Some functions are not available anymore)