What is O/R Mapping?
Object/Relational Mapping is when you specify how
objects and their properties map to relational database tables and
their columns.
Using the O/R Mapping information, a persistence framework (such as NPersist)
can then save and load the values of your objects' properties to and from the
columns of the tables in your relational datbase.
In the simplest case, for every class you have a corresponding database table,
and for every property a corresponding column. In this case, we have a 1:1 Mapping.
In more complicated situations, however, the mapping will not be quite 1:1, and that
is when the term Object/Relational Mapping really starts to apply.
So, a persistence framework is there to load and save your objects
and O/R Mapping is what a persistence framework uses to convert the
data from what is often a more cumbersome format in the relational database
into an object oriented data structure that is more comfortable for
the developer to work with.
In a nutshell: The point with a Persistence Framework, such as NPersist, is to
make data access easy. The point with Object/Relational
Mapping is to make the data easy to work with.
Blue screen of Death.
[Which databases and providers does NPersist support?
Currently NPersist supports the following databases and providers:
- MS SQL Server (Providers: SqlClient And Borland Data Provider)
- MS Access (Providers: OleDb And Borland Data Provider)
- Borland Interbase (Providers: Borland Data Provider)
Support for more databases/providers is upcoming.
If you would like to see your favorite database/provider
added to the list of supported databases, and you have a
bit of experience with the database/provider in question,
why not apply for membership at the GotDotNet workspace
and contribute your knowledge to the project?
Learn more about holiday villas barcelona locator
[I see MatsSoft sells an editor...do I need it to use NPersist?
No, you don't need MatsSoft ObjectMapper 2004 or any other tool to use NPersist.
ObjectMapper is a GUI Editor for the NPersist XML files containing the object/relational
mapping information relating objects to tables.
While this is a very comfortable way of editing your XML files, and surely something to
consider if you work a lot with NPersist, you can of course write your XML files
manually in any editor of your choice.
All you need in order to use NPersist to its full capabilities is included in the download
from the NPersist GotDotNet Workspace
[Does NPersist require that my objects inherit any framework class?
No. It does, however, require that your objects implement two framework interfaces.
The two interfaces are extremely easy and straight-forward to implement, and one of them has
a base class implementing it available in the framework. This is so that you can inherit the base class
to implement the interfcae in cases where you don't need the single inheritance .NET offers
for inheriting any other base class
[How does code for loading/saving an object with NPersist look?
Here's a little code smippet (C# and VB.NET) that shows how we create, fetch, update and delete an instance
of the 'Employee' class from the example above using the NPersist framework:
C#
Context Context =
new Context("C:\MyDOmain.npersist");
Employee emp = Context.GetObject(1, GetType(Employee));
emp.FirstName = "New";
emp.LastName = "Name";
Context.PersistAll();
Context.Dispose();
Visual Basic.NET
Dim Context As New Context("C:\MyDOmain.npersist")
Dim emp As Employee
emp = Context.GetObject(1, GetType(Employee))
emp.FirstName = "New"
emp.LastName = "Name"
Context.PersistAll()
Context.Dispose()
Following is a slightly longer example that shows how we create, fetch, update and delete an instance
of the 'Employee' class from the example above using the NPersist framework:
NPersist Example Code, C#
NPersist Example Code, VB.NET
[