You are here: Basics Operations & Concepts > Querying > Native Queries > Native Query Optimization At Build Time

Native Query Optimization At Build Time

If the platform you're running doesn't support optimization at runtime you can use the compile-time optimization. See "Enhancement Tools"

Create the Enhancement Task

First we define the enhancement-task. This task will process the assembly and enhance it.

You can add this to the existing project-files. The .csproj or .vbproj are actually MSBuild-files. Open them with a XML-Editor and add the needed parts.

<Target Name="AfterBuild">
  <Db4oEnhancerMSBuildTask Assemblies="@(Db4oEnhance)" />
</Target>
simple-enhance-example.csproj: Define a target which runs the task

And the execute the task after the compilation.

<Target Name="AfterBuild">
  <Db4oEnhancerMSBuildTask Assemblies="@(Db4oEnhance)" CommandLine="-nq" />
</Target>
simple-enhance-example.csproj: Only enhance native queries

Now Visual Studio will automatically run the tasks for each build. You don't need to change anything else.

Often it's practical to have all persistent classes in a separate project or compile unit. Then the enhancement script runs only for this project. This makes it easy to enhance only the classes for the persistent objects.

There are lot of possibilities to tweak and configure the build-time enhancement so that it fits your requirements. See "Build Time Enhancement"