views:

3004

answers:

10

XPO is the object relational mapper of choice at my company. Any thoughts on the pros and cons?

A: 

The pros and cons compared to what? There are a lot of alternatives out there, the most popular being nHibernate, with the new kid 'ADO.NET Entity Framework' on the block.

Anyways, there are hundreds of answers depending on your situation and requirements.

Nicholas
+4  A: 

Others will probably pitch in with technical answers (e.g. the query syntax, use of caching, ease or otherwise of mapping to an existing database structure) -- but if you have an established ORM layer the answer is probably

"Why change"?

I've used XPO successfully for years in an established commercial product with several hundred users. I find that it's fast, flexible and does the job. I don't see any need to change at the moment, as our data volumes aren't particularly large and the foibles (caching, mostly) are things we can work around.

If I were starting afresh I'd definitely look at both NHibernate and the ADO.NET Entity Framework. In practice, though, all are good; I'd most likely look at the commercial situation for the project ahead of the technical questions.

For instance, NHibernate is open-source -- is there a viable community there to support the tool and to provide (if necessary) commercial support?

XPO comes from a tools vendor, are they likely to remain in business for the lifetime of the product?

ADO.NET Entity Framework comes from Microsoft, who are notorious for changing database technologies more often then Larry fills his fighter with jet fuel -- will this, too, fade away?

Jeremy McGee
A: 

I was just looking for general feeling and anecdotes about the product. We are not switching to XPO. We are just getting rid of hard coded sql strings living in the app and moving completely to ORM for all data access.

kazakdogofspace
A: 

I like the fact that you can just create classes, and xpo creates the tables and relationships for you - so you can start from a blank database.

One issue I don't like is when I want to delete a whole bunch of stuff, it will go through my collection and do a delete on each one. This takes ages, so for this kind of instance, I've had to write some custom sql (delete from table where blah). I'm no expert on XPO, but that's what I found.

Dave Arkell
A: 

I second the fact the deleting complex objects with some collections take really, really long. So far the documentation or the forums were not able to help me with this.

Apart from that it is really simple to use and gets you going quickly.

It is also quite hard to figure out your memory usage, I had complex big objects in my design and working with them was a memory hog bigger than I had assumed.

Tomas Pajonk
+3  A: 

I have found XPO very frustrating to work with. The main idea of an ORM is to abstract away the underlying data structure. But very quickly you'll notice that they have the default string length hardcoded to 60 chars, so you end up adding these ugly string.unlimited things around every string. So much for abstraction...

When modelling more complex object you have to use a lot of syntax that really has no place in your object model, like XPCollection. I wanted to store a class which had a dictionary of strings on the class, but sadly XPO was not able to automatically store this into the database.

So while it works ok for simple types, it very quickly breaks down when you want to store more complex things. That combined with their mediocre support really leaves a LOT to be desired.

Anders Rune Jensen
+1  A: 

XPO is real pain when you plan to work with legacy database, because many of its features mess up with DB schema. Most painful obstacles I hit were:

  • all objects need to inherit from XPO related classes - no POCO objects
  • no support for keys of type long
  • no support for readonly persistent fields
  • you cannot do many-to-many relation mapping with your own interim table. Xpo wants specific name for such interim tables.
  • no support for pre filtering associations
  • Poor support for foreign composite keys
  • no support for db schema in postrgeSql provider
  • no support for enums in postgreSql provider
  • no serialization, so XPO objects are hard to use in disconected win forms scenario, with data coming through web services
  • many small annoyances

XPO is good for small, new projects. If you convert brownfield applications or want to do something bigger than few projects app, keep away from it.

Przemaas
The postgre qualms are edge cases considering all of the other - more common - DBs supported. 2 is wrong, inherit from XPCustomObject. 3 as well is only applicable if you are using generated fields. 4 is counter to the intent of an ORM. WRT 9, use a Jet provider instead, and serialize it yourself if you're using WCF/Web Services. Don't get me wrong, I'm no xpo evangelist; this is just a poor list.
SnOrfus
2 is not wrong. If you inherit from XPCustomObject and put KeyAttribute on field of type Int64, you end up with exception. KeyAttribute works only with Int32 or Guid fields unfortunately. 3 is applicable to generated fields - agreed. This is exactly issue I refer to. There is no way to handle such fields now with XPO. WRT 4 - what do you mean by "counter to the intent of an ORM"? I need to reflect schema of my existing DB. I cannot rename tables to be consistent with "intent of ORM". I need ORM to be flexible enough to cover my legacy scenarios.
Przemaas
PostreSql issues are corner cases - agree. I hope Xpo providers for other DBs are bug free and allow to work with newest features of those DBs. You call my list poor, but all of these issues are real obstacles when you hit them while working with legacy DB and Xpo.
Przemaas
A: 

I've been working with it for 6-7 months now and the seller for me was the fact that all of their UI components work relatively seamlessly with XPO - and their UI components are top notch.

Some might note that their forums are poorly monitored and have little useful traffic - this is true. The secret is to fill out tickets though. They respond quickly, and accurately to all of their support tickets.

SnOrfus
A: 

This is all you need to do to start writing your domain objects (try do the same in other systems):

using System;
using DevExpress.Xpo;
using DevExpress.Data.Filtering;
using NUnit.Framework;

namespace XpoTdd {
    public class Person:XPObject {
        public Person(Session session) : base(session) { }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        [Persistent]
        public string FullName { get { return FirstName + " " + LastName; } }
    }
    [TestFixture]
    public class PersonTests {
        [Test]
        public void TestPersistence() {
            const string connStr = "Integrated Security=SSPI;Pooling=false;Data Source=(local);Initial Catalog=XpoTddTest";
            UnitOfWork session1 = new UnitOfWork();
            session1.ConnectionString = connStr;
            Person me = new Person(session1);
            me.FirstName = "Roman";
            me.LastName = "Eremin";
            session1.CommitChanges();
            UnitOfWork session2 = new UnitOfWork();
            session2.ConnectionString = connStr;
            me = session2.FindObject<Person>(CriteriaOperator.Parse("FullName = 'Roman Eremin'"));
            Assert.AreEqual("Roman Eremin", me.FullName);
        }
    }
}
Roman Eremin