* ADO.NET
** Data Access in Mono
- Today, our goal is to be compatible with .NET 1.0 and .NET 1.1. We also would like
to extend data access beyond what is included with .NET 1.0 and .NET 1.1,
such as, including 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
would include features like:
- ObjectSpaces
- provide support for hosting Mono languages (C-Sharp, MonoBASIC, etc...)
within a DBMS engine, such as, MySQL or PostgreSQL.
- implement .net 1.2 classes, such as, those found in System.Data.ProviderBase
- other stuff which can be brought up on the mono-list
** 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:
Providers which we do not have, but we would like to have. Currently,
some of these databases are supported via the ODBC or OLE DB providers.
- Managed Classes for SqlXml which is
a .NET data provider for retrieving XML data from a Microsoft SQL Server 2000 database. The System.Data.SqlClient provider
in Mono can be used as a starting point at mcs/class/System.Data/System.Data.SqlClient.
- miniSQL
- BerkeleyDB (Sleepycat)
- SapDB
- Informix
- Foxpro
- Microsoft Access - could be done by creating C# bindings to MDB Tools
- dbase or xbase type database files
- Others are welcome
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).
SQL# command line query tool is a command-line tool to
enter and execute SQL statements or
execute a batch of SQL commands from a file.
It can
be used to test connection strings, connect to various ADO.NET
providers, save output to text, html, or xml.
The SQL# CLI is distributed with the
Mono runtime and class libraries as an executable assembly sqlsharp.exe.
The source to SQL# CLI can be found in the mcs source at
mcs/tools/SqlSharp/SqlSharpCli.cs
SQL# For GTK# - is a graphical SQL database query tool allows a user
to enter SQL commands in a top panel which is a text editor.
It has a toolbar and menu for various tasks, such as, executing
SQL commands one-at-a-time or in a batch. The results would appear
in a bottom panel in a grid or could be saved to a file (xml, html, csv).
Also, the bottom panel would allow logging of SQL command executed.
Here is a screenshot of SQL# For GTK# which
provides a GUI interface using the Gtk# toolkit.
SQL# For GTK# can be found in mono cvs as sqlsharpgtk.
Tools we would like to have, but they have not been created yet:
- Mono has an XML Schema Definition tool (xsd.exe).
- This tool
would works like the xsd.exe tool included with
the .NET Framework. The Xsd.exe tool has the
following uses:
- 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
- Xsd.exe is used to manipulate XML schemas that
follow the http://www.w3.org/XML/Schema">XML Schema Definition (XSD) language
recommended by the World Wide Web Consortium (W3C)
- How this tool could be created:
- Write xsd.exe in C# and run on Mono
- Make sure we have XML Schema support in System.Xml.Schema. Currently,
it is wrapped around libxlst
- XML serialization support in System.Data classes
- Create the TypedDataSetGenerator class in System.Data
- Using CodeDOM or Reflection.Emit to create code
- Make sure DataSet, XmlDataDocument, and related classes
are implemented fully
Application XML Configuration File Editor - a tool
to create and edit an application configuration file, such as,
we have a .net application named Accouting.exe, the tool could edit
the application configuration file Accounting.exe.config so a user could
connect to the database used by the program. This tool has not
been created.
Configuration Command-Line and GUI Tools for ADO.NET.
These tools have not been started. The tools would be written in
C# and run on Mono. The
configuration tool can be used to do the following:
- bebased on the Application XML Configuration File Editor
- setup DSNs for the ODBC and OLE-DB
providers and configurations for
their underlying libraries (unixODBC and libgda)
- setup configurations for the Mono.Data.ProviderFactory
that Brian Ritchie created
- setup native database client library configurations too, such as,
freetds.conf for Microsoft SQL Server and Sybase
** 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.
** Current Status
Various ADO.NET Providers have been created at various stages of
development including:
Firebird/Interbase, IBM DB2 Universal Database, MySQL, ODBC, OLE DB, Oracle,
PostgreSQL, SQL Lite, Sybase, Microsoft SQL Server, and TDS Generic.
See their respective web page for more information.
Data Relations via DataRelation, DataRelationCollection, and
other classes have not been implemented
Constraints need lots of work
XML Schema Definition tool xsd.exe that is included
in the .NET Framework has not been created for Mono
TypeDataSetGenerator needs to be stubbed and implemented.
DataSet, DataAdaptor, DataTable, DataRelation, DataRow, DataColumn,
DataColumnCollection, DataRowCollection, and others need more work. There are
many classes that are just stubs and need to be implemented. Ville Palo has been
doing much testing here.
XML support in System.Data needs work. This involves working on
the classes: DataSet, XmlDataDocument, and the method ExecuteXmlReader() that
exists in a provider's class that implements IDbCommand, and others.
Stuart Caborn has started the XML support in a DataSet. Tim Coleman started
XML support in the ExecuteXmlReader() in a SqlCommand. Ville Palo has been
heavily modifying DataSet, XmlDataDocument, and other classes for reading
and writing XML. XML Serialization support in DataSet needs to be implemented.
Integration with ASP.NET has been created. Data binding of
a DataTable in a DataSet to a System.Web.UI.WebControls.DataGrid works. Data binding
of other types works too.
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:
"Mono.Data.PostgreSqlClient"
- DBConnectionType is the System.Type of the class that
implements System.Data.IDbConnection that is found
in the DBProviderAssembly.
For example:
"Mono.Data.PostgreSqlClient.PgConnection"
- 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.
Integration with Windows.Forms has not been started, such as, data binding
to a System.Windows.Forms.DataGrid. This may involve implementing many classes
in System.Windows.Forms and System.Data.
Integration with GTK#
has not been started, such as, data binding
to a GtkTreeView. This may involve creating new classes
to go between the glist data model and the ADO.NET data model.
Mike Kestner or Rachel Hestilov would be the best people to ask for help on GTK#.
Integration with QT# has not been started. Any information on
how this can be done is appreciated. Marcus would be the best
person to ask about QT#.
Building System.Data
The System.Data.dll gets built with the rest of the class library.
To compile the System.Data.dll assembly separately, you need:
On Unix
* update your mono sources. Be sure you have latest mcs.exe
and .dll's, since there have been many fixes needed for
compilation on Linux.
* compile System.Data.dll:
cd mcs/class/System.Data
mcs --target library -o \
System.Data.dll @list
On Windows
* update your mono sources. Be sure you have latest mcs.exe
and .dll's. You can use the same method as Linux,
or you can use NAnt.
* To use NAnt:
cd mcs/class/System.Data
../../nant/NAnt.exe
* This will automatically copy the System.Data.dll to Test.
If you need to do a clean for the System.Data.dll assembly,
cd mcs/class/System.Data
../../nant/NAnt.exe clean
** 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 (Mono) |
Mono.Data.PostgreSqlClient / Mono.Data.PostgreSqlClient |
PostgresTest.cs at System.Data/Test |
MySQL (Mono) |
Mono.Data.MySql / Mono.Data.MySql |
MySqlTest.cs at Mono.Data.MySql/Test |
Oracle (Mono) |
System.Data.OracleClient / System.Data.OracleClient |
TestOracleClient.cs at System.Data.OracleClient |
ODBC (Mono) |
System.Data.OracleClient / System.Data.OracleClient |
TestOracleClient.cs at System.Data.OracleClient |
- 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:
- On Linux: make -f makefile test
- On Windows: make test
- 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:
- On Linux: make -f makefile test
- On Windows: make test