Table of Contents

Class FnBlock

Namespace
Breeze.Core
Assembly
Breeze.Core.dll

A function call in a query, such as "toupper(CompanyName)" or "year(OrderDate)".

public class FnBlock : BaseBlock
Inheritance
FnBlock
Inherited Members

Remarks

The functions a query may call are fixed, registered by the static constructor below and listed by name together with their return and argument types. They follow the OData set: the string functions, the date parts, and rounding.

Constructors

FnBlock(string, List<BaseBlock>)

Create a call to a registered function.

public FnBlock(string fnName, List<BaseBlock> exprs)

Parameters

fnName string

The function name.

exprs List<BaseBlock>

The argument blocks, in order.

Properties

DataType

The data type the function returns.

public override DataType? DataType { get; }

Property Value

DataType

Expressions

The arguments passed to the function, in order.

public IEnumerable<BaseBlock> Expressions { get; }

Property Value

IEnumerable<BaseBlock>

FnName

The name of the function being called, e.g. "toupper".

public string FnName { get; }

Property Value

string

Methods

CreateFrom(string, Type)

Parse a function call written as text.

public static FnBlock CreateFrom(string source, Type entityType)

Parameters

source string

The call, e.g. "toupper(CompanyName)".

entityType Type

The entity type any property arguments are resolved against.

Returns

FnBlock

The parsed call.

GetArgTypes(string)

The argument types a registered function takes, in order.

public static List<DataType> GetArgTypes(string fnName)

Parameters

fnName string

The function name.

Returns

List<DataType>

One type per argument.

Exceptions

KeyNotFoundException

No function is registered under that name.

GetReturnType(string)

The type a registered function returns.

public static DataType? GetReturnType(string fnName)

Parameters

fnName string

The function name.

Returns

DataType

The return type.

Exceptions

KeyNotFoundException

No function is registered under that name.

RegisterFn(string, params DataType[])

Register a function that queries may call. Names are matched case-insensitively.

public static void RegisterFn(string name, params DataType[] dataTypes)

Parameters

name string

The function name as clients will write it.

dataTypes DataType[]

The return type first, then one type per argument.

ToExpression(Expression)

Build the call as a LINQ expression, mapping the function name onto the matching CLR method or property.

public override Expression ToExpression(Expression inExpr)

Parameters

inExpr Expression

The query's lambda parameter.

Returns

Expression

The expression that computes the function's result.

Exceptions

Exception

The function is registered but has no expression mapping here.