 |
Review: eXpress Persistent Objects
|
eXpress Persistent Objects 2006, $199.99 with full
source code, $149.99 without source code
Developer Express
Las Vegas, Nevada
(702) 262-0609
http://www.devexpress.com/Products/NET/XPO/
eXpress Persistent Objects (XPO) is an object-relational mapping
product (that is, it handles storing business objects in a
relational database and getting them back out) with some very nice
features. For starters, you can just about completely avoid thinking
about databases at all when you use XPO. Not only will it save
objects to the database and get them back out, it will take care of
creating the database and designing the tables for you as well; you
never even have to open the database file if you don't want to. It's
quite possible that the only line of database-specific code you'll
ever write in an XPO-enabled application is one to set the
connection string. By default, XPO uses a Microsoft Access database,
but it also supports SQL Server, MySQL, Oracle, PostgreSql,
Firebird, PervasiveSQL, VistaDB, SQL Anywhere, Advantage, DB2 and
Sybase. (If you do have an existing database, you can also control
the mapping so you can build objects from this database).
Creating business objects that are handled by XPO is pretty
darned simple: just set the right references and inherit your
objects from XPObject. XPO provides attributes to let you customize
things such as the way inherited classes are stored in the database,
which objects are aggregated in other objects, and associations
between objects. For example, here are a pair of simple business
object classes with a many-to-many relationship:
public class Physician : XPObject
{
public string FirstName;
public string LastName;
public string Specialty;
[Association("PatientsPhysicians", typeof(Patient))]
public XPCollection Patients { get { return GetCollection("Patients"); } }
// Constructor that accepts a session
public Physician(Session session) : base(session) {}
}
public class Patient : XPObject
{
public string FirstName;
public string LastName;
public string Complaint;
[Association("PatientsPhysicians", typeof(Physician))]
public XPCollection Physicians { get { return GetCollection("Physicians"); } }
// Constructor that accepts a session
public Patient(Session session) : base(session) { }
}
After you have the minimal amount of plumbing in, working with
XPO is simple. It's one call to .Save() to persist your object to a
database. It's one call to the XPCollection constructor to retrieve
all the objects of a particular type into a collection. For the most
part, you can simply forget that the backing store is there at all,
and assume that you load and save your objects from somewhere out
there that's reliable and invisible, which, come to think about it,
is a pretty good idea of how you want your database to behave.
XPO provides support for multi-level caching for performance, or
for shareable stateless data access for ASP.NET applications. You
can perform transactional work using the UnitOfWork object, and save
all changes made to a group of objects back to the data store with a
single method call. On the object level, you get delayed loading
(useful for large or infrequently-used properties), a good criteria
system for finding particular objects in the data store, and support
for custom keys. All in all, there is a large amount of useful
functionality here, and when you know what you're doing with it, XPO
appears to be very powerful indeed.
That's where my one reservation with this product comes in: the
help and samples provided simply do not adequately showcase the
product's abilities. The help itself, while containing pages on most
of the major functionality, is poorly organized and doesn't have any
serious tutorial sections. The half-dozen samples don't cover the
full breadth of the product, and there are some huge holes - for
instance, there's no "best practices" ASP.NET sample at all. While
technical articles on the Developer Express Web site fill in some of
the gaps, and there is more information starting to show up on their
community site as
well, a product this complex really needs to do more to help people
over a complex learning curve. If you're working with objects that
need to be persisted I urge you to take a look, but be prepared to
set aside a day or two to really dig in and decide whether it will
work for you.
Fortunately, you can
download a demo so that playing with it doesn't risk anything
more than your time. As with other Developer Express products,
there's good support available via newsgroups and an online
KnowledgeBase.

Mike Gunderloy is
the lead developer for Larkware and author of numerous books and articles on
programming topics.
Published April 17, 2006
|