.NET Expressions
API v2 uses LINQ expression parser that use syntax that is very close to standard .NET syntax. There are some difference:
- Casts are supported via
Assignable.As<UserStory>
. You can access any simple or reference field of a specific type, like:Assignable.As<UserStory>.Epic.Name
. Collections on casted entities are not supported! - You can use Convert class to convert strings to numbers or dates or vice versa.
- Decimal values are converted to double(nullable double) automaticaly in case double and decimal values are used in one expression: result of
it.Double + it.Decimal
andit.NullableDouble * it.Decimal
will bedouble
anddouble?
. You don't need to useConvert.ToDouble(it.Decimal)
. This also works for IFNONE/IIF operators: you can simply writeIFNONE(it.NullableDouble, it.NullableDecimal)
orIIF(it.NullableDecimal.HasValue, it.NullableDecimal.Value, it.Double)
. - Nullable bool is automaticaly converted to bool (false for null value). So if nullable bool is used in place where bool should be used it's usage will be converted from
it.NullableBool
toit.NullableBool == True
. - Constructors are not supported, but you can construct your anonymous objects using syntax described above:
{ex1,ex2}
- You can use static methods of some types (DateTime, Convert, Guid). E.g.
DateTime.Today
,Convert.ToInt
- You can use Nullable types and checks for nulls
- You can use instance methods of simple types (e.g.,
object.ToString()
,string.Length
) - You can use IIF operator instead of
a?b:c
- You can use IFNONE operator:
IFNONE(a,0)
instead ofa.HasValue?a.Value:0
- You can use operators (
-
,+
,*
,/
), comparisons (<
,>
,<=
,>=
,==
), Boolean constants (true
,false
), string constants ("Some string"
), chars ('c'
) andnull
identifier. - Do not forget that
+
sign is treated as space in URLs so do not forget to replace it with%2b
. - You can use operator
in
(id in [1,2,3]
)
Also some limited subset of IQueryable methods are supported for nested collections (e.g. bugs of user story):
Select(
selector)
- projection as described aboveWhere(
filter)
- filters as described belowSum(
expression)
(as well as Max, Min, Average) - aggregations over specified expressionCount(
filter)
- count of filtered items
Updated 18 days ago