There are three steps to using the iBATIS Data Access Objects (DAO) framework with your application for the first time.
The official site for iBATIS for .NET is our Apache site <http://ibatis.apache.org/>. The DataAccess framework is availabe in 2 types of distributions: a binary distribution that includes the required DataAccess assemblies and a source distribution that includes a VSN solution. To download either of the distributions, follow the link to the Downloads area on our web site, and select the either the binary or source distribution for the iBATIS .NET DataAccess V1.6.1 or later release (if you download the binary distribution, extract the files using a utility like WinZip or the extractor built into newer versions of Windows and skip ahead to the Add Assembly References section).
The source distribution includes a VSN solution and a number of C#
projects. The distribution is in the form of a ZIP archive. You can
extract the distribution using a utility like WinZip or the extractor
built into newer versions of Windows. We suggest that you create an
ibatisnet folder in your VSN project directory and
extract the distribution there.
Under the distribution's
source folder are
eight folders that make up the iBATIS.NET distribution, as shown in the
Table 3.1. Folders found in the iBATIS.NET source distribution
|External-Bin||Dependency assemblies provided for your convenience.|
|IBatisNet.Common||Assembly of classes shared by DataAccess and DataMapper|
|IBatisNet.Common.Test||Test project for IBatisNet.Common that can be used with NUnit|
|IBatisNet.DataAccess||The Data Access Objects framework|
|IBatisNet.DataAccess.Extensions||Contains a C# project for extensions to the DataAccess framework such as NHibernate support|
|IBatisNet.DataAccess.Test||Test project for the DataAccess framework that can be used with NUnit|
|iBatisNet.DataMapper||The DataMapper framework (see seperate DataMapper Guide)|
|IBatisNet.DataMapper.Test||Test project for the DataMapper that can be used with NUnit|
You can load the
IBatisNet.sln solution file
into VSN and build the solution to generate the needed assemblies. There
are seven projects in the solution, and all should succeed. The
assemblies we need will be created under
\source\IBatisNet.DataAccess\bin\Debug. The created
assemblies are :
The core DataAccess framework has external dependencies on
The dependency is found in the
External-Bin folder and can also
be found in the
bin\Debug folder after building the
solution. In addition, the framework's
IBatisNet.DataAccess.Test projects have
dependencies on NHibernate.
If you will not be using NHibernate and have a problem building the solution due to that dependency, simply remove the IBatisNet.DataAccess.Extensions and IBatisNet.DataAccess.Test projects from the solution before building.
Switching to your own solution, open the project that will be using the iBATIS.NET DAO Framework. Depending on how your organize your solutions, this might not be the project for your Windows or Web application. It may be a library project that your application project references. You need to add two references to your project:
Additionally, the DAO framework has the following external dependencies:
Table 3.2. Dependencies
|Castle dynamic proxy 220.127.116.11||Dynamic proxy generator||Castle.DynamicProxy.dll|
You will need to add two or more XML file items to your Windows or Web application project (and Test project if you have one). These files are:
providers.config files must be placed in a location
where the framework can find them at runtime. Depending on the type of
project you have, the default expected location of these 2 files will be
different, as shown in Table 3.3. However, your project is not limited
to using just these locations. The DataAccess framework provides other
options for placing these files in locations that are more suitable for
your project instead of using the default locations. These options are
covered later in this guide.
Table 3.3. Where to place the dao.config file
|Windows, Library, or Test projects (using NUnit or equivalent)||Place with the assembly (.dll) files and the
|Web projects||Place in the project root, with the
The configuration file (dao.config) is associated to a schema. The benefits of associating an XML document with a schema are to validate the document (which is done at runtime) and to use editing features such as IntelliSense/content completion assistance.
To allow association of the schemas in VS.NET XML editor to your
configuration file, you should add the schema file
DaoConfig.xsd to either your VS.NET project or in
your VS.NET installation directory. The VS.NET directory will be
C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas for VS.NET 2005
C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\Packages\schemas\xml for VS.NET 2003
C:\Program Files\Microsoft Visual Studio
.NET\Common7\Packages\schemas\xml for VS.NET 2002
depending on your version of VS.NET. It is typically easier to place the file in the well known location under the VS.NET installation directory than to copy the XSD file for each project you create.
Once you have registered the schema with VS.NET you will be enough to get IntelliSense and validation of the configuration file from within VS.NET.