It's simple: http://www.castleproject.org/activerecord/documentation/trunk/advanced/accessingmoredbs.html
That's all. AR takes care that all schemas are created when you call ActiveRecordStarter.CreateSchema(); If you just want to create the schema for one database, call ActiveRecordStarter.CreateSchema(typeof(Baseclass)) instead. But that also means that AR needs to know the baseclass when you do a query that isn't bound to one of your entities. Somehow it has to find out which db to use... -Markus 2010/7/12 Visar Uruqi <[email protected]>: > Thank you very much Markus for your reply, I will try to implement > what you said, > > What about resources in AR, it seems there is a lack of edu material, > or I can not find it, do you know a place in the cloud where I can > find > good lessons,manual,articles in AR? > > Didn't knew that AR can pull out Data from multiple Databases although > I have no idea how this is implemeted, I use in Global.asax something > like this > > protected void Application_Start(object sender, EventArgs e) > { > Castle.ActiveRecord.Framework.IConfigurationSource source > = > > System.Configuration.ConfigurationManager.GetSection("activeRecord") > as > Castle.ActiveRecord.Framework.IConfigurationSource; > > > Castle.ActiveRecord.ActiveRecordStarter.Initialize(typeof(Post).Assembly, > source); > //Castle.ActiveRecord.ActiveRecordStarter.CreateSchema(); > } > > to initialize AR. this is one database, what about the initialization > of the second Database > where is going to take place?, do I need a separate DomainModel, how > is this handled, > its very interesting... is the code below OK (for connecting to two > different Databases). > > protected void Application_Start(object sender, EventArgs e) > { > //=====================First Database================================ > > Castle.ActiveRecord.Framework.IConfigurationSource source > = > > System.Configuration.ConfigurationManager.GetSection("activeRecord") > as > Castle.ActiveRecord.Framework.IConfigurationSource; > > > Castle.ActiveRecord.ActiveRecordStarter.Initialize(typeof(Post).Assembly, > source); > //Castle.ActiveRecord.ActiveRecordStarter.CreateSchema(); > > //=====================Second Database================================ > > Castle.ActiveRecord.Framework.IConfigurationSource source > = > > System.Configuration.ConfigurationManager.GetSection("activeRecord_2") > as > Castle.ActiveRecord.Framework.IConfigurationSource; > > > Castle.ActiveRecord.ActiveRecordStarter.Initialize(typeof(SomeEntityforTheSecondDatabase).Assembly, > source); > //Castle.ActiveRecord.ActiveRecordStarter.CreateSchema(); > > //===================end so on.... > } > > On Jul 12, 3:23 pm, Markus Zywitza <[email protected]> wrote: >> Hi Visar >> >> The target type is not the type being returned. AR allows to use >> multiple databases. The database for each type is chosen through an >> abstract baseclass. Without providing the target type, AR cannot know >> which session or session factory it has to use to run the query. The >> return of SimpleQuery.Execute() is AFAIR always object[][], >> independent of target type. >> >> If you don't use multiple databases and have no clear candidate for >> target type, you can simply use ActiveRecordBase, which is the >> abstract base class for types using the default database, even for >> those types that don't have a base class other than object. >> >> -Markus >> >> 2010/7/12 Visar Uruqi <[email protected]>: >> >> > Why do I have to provide always the target type, when I build a query >> > be it custom query, SimpleQuery, HqlBasedQuery always I have to write >> >> > new SimpleQuery(typeof(SomeObject) ,... >> > new HqlBasedQuery(typeof(SomeObject) ,... >> >> > Can't I just write HQL and parse, or Transform the result to some >> > CustomObject? >> >> > On Jul 12, 1:26 pm, Visar Uruqi <[email protected]> wrote: >> >> Hello >> >> >> I'am new to ActiveRecord but not to Nhibernate, I've done two projects >> >> with Nhibernate. >> >> Since I saw a presentation from ayende for Castle ActiveRecord, I was >> >> blown away and want to learn all what ActiveRecord has to offer, I've >> >> started something with ActiveRecord but I'm having a problem when I >> >> want to return multiple entites, I looked at the documentation >> >> >>http://www.castleproject.org/activerecord/documentation/v1rc1/usersgu... >> >> >> but still can not figure out how to return multiple entities and >> >> tranform them via AliasToBean<ReportingObject> ? >> >> what is the best way to do query's with joins where the result is >> >> mixed with fields from many entities? >> >> How to transform them to an object that is not (say) part of the >> >> DomainModel (not persisted) but just for reporting >> >> purposes? >> >> >> IS THERE A BOOK FOR CASTLE ACTIVE RECORD? >> >> OR A USER MANUAL? >> >> Where can I find resources for Castle Active Record? >> >> >> Thank you for your time >> >> > -- >> > 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 >> > athttp://groups.google.com/group/castle-project-users?hl=en. > > -- > 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. > > -- 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.
