* ADO.NET
** Data Access in Mono
- Today, our goal is to be compatible with .NET 1.1 and .NET 1.0. We also would like
to extend data access beyond what is included with .NET 1.0 and .NET 1.1,
such as, include access to more databases, such as, PostgreSQL and MySQL,
but also provide classes that help in creating data source-agnostic code, such as,
Mono.Data.ProviderFactory.
- In the future, we would like to be compatible with .NET 1.2. This includes features
like ObjectSpaces
** Bugs and Feature Requests
- Bugs with Mono or any data provider in Mono should be reported
in Mono's Bugzilla here. If you
do not have a Bugzilla user account, it is free
and easy to create
one here.
- Any requests for new features or missing functionality
can entered as a bug in Bugzilla too
** ADO.NET Data Providers
Mono has many ADO.NET Data Providers to get you connected:
External Projects that have created ADO.NET Providers that work on Mono:
- Firebird Interbase
is a
Firebird SQL Managed data provider. It can be used with Interbase databases too. It
is written in 100%C# and does not require a client library. Works on .NET and Mono.
- Npgsql is a
PostgreSQL Managed data provider written
in 100% C#, does not require a client library, and works on .NET and Mono
- MySQLNet is a
MySQL Managed data provider written in 100% C#, does not
require a client library, and works on .NET and Mono
** Tools
Some tools that can be used for ADO.NET and other technologies (ASP.NET, XML, etc).
- sqlsharp.exe
- SQL# is a command line query tool included with Mono to enter and execute SQL statements
- xsd.exe
- XML Schema Definition tool
- XDR to XSD - used to generate an XML schema from an XDR (XML Data Reduced schema) file.
XDR was used by Microsoft prior to XSD becoming a W3C recommendation. So, this needs
to be supported for legacy reasons
- XML to XSD - used to generate an XML schema from an XML file
- XSD to DataSet - used to generate DataSet classes from an XSD schema file. The
DataSet classes created can then be used with XML data
- XSD to Classes - used to generate classes from an XSD schema file. The
classes created can be used with System.XML.Serialization.XMLSerializer
to read and write XML code that follows the schema
- Classes to XSD - used to generate an XML schema
from type(s) in a assembly file. The
XML schema created by the tool defines the XML format used
by System.XML.Serialization.XMLSerializer
** Extra Classes in Mono ADO.NET
An ADO.NET Provider Factory
was created by Brian Ritchie. The
Provider Factory is a way to dynamically create
connections, commands, parameters, and data adapters based on configuration
information.
** Database Access from ASP.NET
- Take a look at xsp in cvs and look at the examples in test: dbpage1.aspx
and dbpage2.aspx:
- Notice that the namespace System.Data is imported via import
- A NameValueCollection is gotten using ConfigurationSettings.AppSetings. These
settings are gotten from the file server.exe.config which is a XML file. The XML
file has a section appSettings. In the appSettings section, you have keys
for DBProviderAssembly, DBConnectionType, and DBConnectionString.
- DBProviderAssembly is the assembly of the ADO.NET provider.
For example:
"ByteFX.Data"
- DBConnectionType is the System.Type of the class that
implements System.Data.IDbConnection that is found
in the DBProviderAssembly.
For example:
"ByteFX.Data.MySqlConnection"
- DBConnectionString is the ConnectionString to set to the
IDbConnection object to use in opening a connection to a data source.
For Example:
"hostaddr=127.0.0.1;user=monotest;password=monotest;dbname=monotest"
- The function GetConnectionData() gets the database provider assembly, connection type,
and connection string parameters if they exist; otherwise, it uses default values. This is
done during the loading of the web page.
- With the connection parameters, the assembly is loaded, the connection type is verified that
it implements IDbConnection and an instance of the class can be created, creates a instance
of the class, sets the connection string, and opens the connection.
** Testing
- Testing connection-oriented classes are done
via the provider specific tests
found in the mcs source at mcs/class
Name |
Assembly / Namespace |
Test |
Microsoft SQL Server |
System.Data / System.Data.SqlClient |
SqlTest.cs at System.Data/Test |
PostgreSQL (Npgsql) |
Npgsql / Npgsql |
*.cs at Npgsql/Test |
Oracle (Mono) |
System.Data.OracleClient / System.Data.OracleClient |
TestOracleClient.cs at System.Data.OracleClient/Test |
ODBC (Mono) |
System.Data.Odbc / System.Data |
OdbcTest.cs (to connect to MS SQL Server)at System.Data/Test |
- Testing non-connection classes are
done via mono's modified version of NUnit.
- To run all the NUnit tests for Mono, you need the mcs source. cd to the root
of the mcs source. To run it:
- If you just want to run the NUnit tests for System.Data, you would cd into
the mcs source at class/System.Data/Test and run it: