as for your first question: the compiler needs to know or at least be able to infer the type of the returned object in compile time. As in your scenario the type will be determined by the actual data in the DB at runtime, it seem impossible.
as for your second question: questions here are web related cuz people doing web projects were posting them. ActiveRecord is by no means a "web-only" technology. Also, this list serves Monorail questions, (which is 100% web related) but there's no problem at all with posting and sharing non-web knowledge here. On Tue, Dec 16, 2008 at 10:15 AM, KiKi <[email protected]> wrote: > > I notice that most posts on this mailing list are about web-related > project. I wonder if my non-web problem described was posted at the > right place. If there is another forum/mailing list which would be > more appropriate for me, please let me know so I can get help from the > right people. Or if the question is too basic, please let me know as > well so I could elaborate. > > > > On Dec 8, 10:49 am, KiKi <[email protected]> wrote: > > 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 ? > > > -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
