Skip to content

Alternate expression compilers

Jacek Hełka edited this page Aug 3, 2025 · 4 revisions

By default, DbFun compiles code using LambdaExpression<'T>.Compile() method.

You can configure it to use another code generation routine, thanks to compiler abstraction:

type ICompiler = 
    abstract member Compile: body: Expression * [<ParamArray>] args: ParameterExpression[] -> 'Function 
        when 'Function : not struct 

This feature has been added mostly to allow to use FastExpressionCompiler. It significantly improves startup time (compilation is 10-40x faster) and, in some cases, runtime.

To configure DbFun to use FastExpressionCompiler, add DbFun.FastExpressionCompiler package from nuget and replace default compiler in config:

let config = QueryConfig.Default(createConnection).UseFastExpressionCompiler()
Clone this wiki locally