There is a possibility, but it is not very elegant. You can use
DifferentDatabaseScope with your own provided IDbConnection, which
includes the username and password. You will have to manage the
connection youself such as this:

using (IDbConnection conn = new SqlConnection(...))
using (var scope = new DifferentDatabaseScope(conn))
{

}

Alternatively, you can implement your own SessionScope based on
AbstractScope and override OpenSession and PerformDisposal.

-Markus

2009/5/7 Darius Damalakas <darius.damala...@gmail.com>:
>
> I am doing a performance upgrade for my desktop app, and i want to
> make it start faster.
>
> Now, the time between login screen is closed when the user enters his
> username and password, and the main screen appears  is 4 seconds.
>
> From those two seconds the time is spent as follows:
> 1.  Show login form - 200 ms
> 2.  ActiveRecord initialization - 1120 ms   -  building cfg file from
> our 50 class domain model, and loading it
> 3. Find user login info and load security info - 550 ms
>  (this involves also invoking  NHibernate.Impl.SessionFactoryImpl
> constructor)
> 4.  Build main window - 814 ms
> 5. Populate main window with data from db 1101 ms
> 6. a call to Application.Run   - 200 ms
>
>
> Now i have already moved some of the stuff to another thread, so when
> the user is typing his username password (and i bet he does not that
> in less than 1 or 2 seconds), some of the stuff is already
> precalculated.
>
>
> Now my problem is that i don't know if it possible to initialize
> active record with our model classes.    ActiveRecord is being
> initialized with this code:
>
> ActiveRecordStarter.ResetInitializationFlag();
> ActiveRecordStarter.Initialize(m_configurationSource, businessTypes);
>
> However, login information is already included in configurationSource.
> So that means i can not move this code to another thread, since i do
> not have username and password.
>
> So, i am thinkin of the following options:
> 1) Maybe is it possible to initialize AR and then just change user
> name and password without reinitializing all models again?
> If yes, could someone give an example.  I believe it might possible
> just simply changing the connection string property in
> m_configurationSource prior to issuing any queries against DB (so that
> NHibernate session factory would not be created yet)
>
> 2) if first option is not possible, then there is another choice:
> create a standard username and password, and connect to database
> always with it. Now, a username and password must be stored somewhere,
> so that will be a problem too, but for the moment let's say i would
> just hard-code it in my dll.
> Now, when the user tries to log in to my application, i would lookup
> for his username and password in some database table (we already have
> that, except it only has user name column, but not password)
>
> 3) if second option is not a right thing to do, then i don't know any
> other option :)
>
>
> Thank you for any ideas
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to castle-project-users@googlegroups.com
To unsubscribe from this group, send email to 
castle-project-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to