O'Reilly logo

Professional Visual Basic 2012 and .NET 4.5 Programming by Todd Herman, Gastón Hillar, David McCarter, Rob Windsor, Billy Hollis, Bill Sheldon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Object-Relational Mapping

While ADO.NET allows a certain degree of abstraction between databases, at its heart it mirrors the database structure. You use a database Connection object that accesses a command that either returns data in the form of a DataReader or populates a DataSet. You work with stored procedures or the database tables to maintain your database. However, as many developers discover, the data types used in the various databases are not the same, and they definitely do not match the data types you use in your Visual Basic applications. This can lead to errors in your application, such as when a database NULL is passed to a Visual Basic type. In addition, some of the interactions may be clumsy, such as when saving the contents of an object to the database, where you may need to map properties to the data in one or more database rows or tables.

To solve this object-to-database mismatch, a number of strategies have been developed. Many developers struggle with this process manually, handwriting a data access layer to convert between .NET and SQL. Another common strategy — and one requiring less work — is to use tools known as Object-Relational Mapping (ORM) tools. These tools either manually or automatically map the data types used in a database to those used by the client program, and vice versa. The best of these enable the actual structure of the database to be hidden from the client program, providing a more natural interaction between the program and the database. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required