>> I have to work against a legacy data source that does not use
identy type columns, but rather alpha fields (e.g. NGR001). XPO appears to
insist on having an autogenerated PK. This would be fine, but I also need
to make sure that the legacy PK remains unique. Is there a "unique"
attribute that can be applied to an object's property? Or is there another
standard method of managing this type of scenario?
Yes, there is an Attribute, "Indexed(unique=true)";
however, I would suspect that a legacy database would already have this
constraint/index applied.
>> What is the standard method of dealing with inheritance across
fairly divergent objects? I have a few properties that are standard for all my
objects (e.g. LastUser, LastEditDate, etc.) If I create a super class that
inherits from XPObject and then inherit from my super class for all my other
objects, XPO wants to create a table for the super class and then sub
tables with a one-to-one relation to it. This might be fine, but its
problematic given my first question, and you end up adding alot of extra data
baggage by querying against what will end up being a rather large table.
All you need to do is mark the subclass (base
class) with an attribute, "NonPersistent()". XPO will then add the
properties to the class that inherits the base class rather than create separate
tables.
>> I've noted there is no "IsDirty"
property on the XPObject class. I can only assume that when the
session.Save() or xpobject.Save() are called that the XPObject is
only processing those objects that have actually changed.
XPO only keeps track of IsDirty when you use
transactions via a session or UnitOfWork AND only if your properties setters
call the SetPropertyValue method method or OnChanged method.
This is a typical setting for an XPO
property:
public string Name {
get { return m_name; }
set {
SetPropertyValue("Name",
ref m_name, value); }
}
private
string
m_name;
This should then work (thanks to a suggestion by another user)
assuming you add it to your base class and remember it only works if you use
transactions and you should never modify object without using them
anyway:
public bool IsDirty { get { return this.Session.IsObjectToSave(this)
|| this.Session.IsNewObject(this); } }
Trevor