Chapter 18: Object-Relational Mapping in .NET


Overview

Relational databases treat data in terms of rows and columns, and objects treat things in terms of arrays and properties. Object-relational mapping (OR mapping) bridges these two worlds so your code can look like object code and still store itself in a relational database.

In this chapter, you'll create a simple object data model for a video store application. You'll learn how to create mapped objects as well as workarounds for common pitfalls and quirks found in ADO.NET that can adversely affect your data model. Let's start by discussing why you may need to worry about OR mapping.

OR mapping provides three main benefits:

  • Encapsulation: This is one of the primary pillars of object-oriented design, and OR mapping extends this concept to the database.

  • Identity: A mapped object has an identity. In concrete terms it has a unique identifier. Most objects that are not mapped to a database lack a real identity independent of the data presented to the end user. Although it's possible to create an identity for the objects using hashcodes or a similar methodology, mapped objects take this to the next logical level.

  • Behavior: Data in a database does not have behavior. By fusing the world of databases to software code, you have the unique opportunity to define how your data should interact with your system in a clean and reusable way.

Visual Basic .NET (VB .NET) takes the partial support for object-oriented programming found in VB 6 to the next level. By leveraging this expanded capability in VB .NET, you're presented with an opportunity to create powerful object systems with persistence into a medium that allows for easy integration with other systems and a simple way of reporting on that data.




Applied ADO. NET(c) Building Data-Driven Solutions
Applied ADO.NET: Building Data-Driven Solutions
ISBN: 1590590732
EAN: 2147483647
Year: 2006
Pages: 214

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net