Hi,
In my project I have PersistentObject class which all persisted
classes derive from (eg: PersistentPerson). The purpose of
PersistentObject is to provide a unique identifier and a few
miscellaneous methods. Now this class must itself derives
ActiveRecordLinqBase<T> to be able to use Linq. If I am not mistaken
ActiveRecordLinqBase<T> must be parametrized with the child class to
be used correctly. Hence I need to make PersistentObject generic as
well. I end up having something like:
[ActiveRecord, JoinedBase]
class PersistentObject<T> : ActiveRecordLinqBase<T> :
IPersistentObject
{
[PrimaryKey(PrimaryKeyType.Sequence)]
virtual public int Id
{
get { return this.id; }
private set { this.id = value; }
}
}
[ActiveRecord]
class PersistentPerson : PersistentObject<PersistentPerson >
{
[JoinedKey]
override public int Id
{
get { return base.Id; }
}
}
It seems pretty much ok so far. The problem is when I want
ActiveRecord to return an object from a given ID. I would like to be
able to do something like:
IPersistentObject myObject = PersistentObject.FindByPrimaryKey(32);
so ActiveRecord would actually find out that ID 32 is a person and
build a PersistentPerson object and returns it so I could cast it in
IPersistentObject to use it.
Is there any way to achieve this ? to be able to use Linq in all my
objects hierarchy and to get ActiveRecord to build objects I don't
know the type of ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---