In order to Integrate OpenAccess ORM, which is Telerik's free object relational mapping tool, with NAnt, you need to make use of NAnt build definition which includes several targets such as clean, build and enhance. These targets will be used to automate the build process for the given OpenAccess ORM domain model.
The clean target is optional and used to clean up the build folder.
<target name="clean">
The implementation looks like as shown below
<include name="${build.dir}/*.*" />
On the other hand, Build target first performs source code building as shown below
<target name="build" depends="clean">
It then embeds the rlinq file as a resource and defines the required references
<include name="${source.dir}/MyModel.rlinq" />
<references>
<include name="System" />
<include name="System.Core" />
<include name="System.Data" />
<include name="Lib/Telerik.OpenAccess.dll" />
<include name="Lib/Telerik.OpenAccess.35.Extensions.dll" />
</references>
Finally, it copies the required OA assemblies as shown below
<copy todir="${build.dir}">
<fileset basedir="${lib.dir}">
<include name="Telerik.OpenAccess.dll" />
<include name="Telerik.OpenAccess.35.Extensions.dll" />
</fileset>
</copy>
The Enhance target runs the OpenAccess ORM enhancer over the built project using the rlinq file as a metadata source as shown below
<target name="enhance" depends="build">
<exec program="${enhancer.file}">
<arg value="-assembly:"${build.file}" -xmlMapping:${source.dir}/MyModel.rlinq"/>
</exec>
</target>
As you can notice, the above code make use of XML mapping.
"There can be scenarios where the model is defined using attributes or fluent mapping. It is possible to combine all of the mapping types in one OpenAccess ORM project," says Damyan Bogoev, Senior Software Developer, OpenAccess ORM Team, Telerik.
OpenAccess ORM enables you to generate data access layer for your applications by creating the data model.