use of sharp architecture in console application

74 views
Skip to first unread message

csetzkorn

unread,
Apr 6, 2010, 7:15:45 AM4/6/10
to S#arp Architecture

Hi,

I am trying to use the out of the box repository of the sharp
architecture in a console application to initialise the database.
However, I get this exception:

ISessionStorage has not been configured

I am using:

IRepository ARepository = new Repository();

A a = new A(); ... ini some properties

ARepository.SaveOrUpdate(a);

This should work or am I missing something?

Thanks.

Christian

csetzkorn

unread,
Apr 6, 2010, 7:26:06 AM4/6/10
to S#arp Architecture
I guess it has to do with the fact that the architecure/Castle usually
takes care of the implementation of certain patterns (e.g. session per
request) within mvc. the question is how can I easily use the
repository in a console application.

Thanks.

Dan

unread,
Apr 6, 2010, 11:07:35 AM4/6/10
to S#arp Architecture
You probably just need to create a SimpleSessionStorage object when
calling the NHibernateSession.Init.

// change mapping assemblies as necessary
string[] mappingAssemblies = new string[] { "MyProject.Data" };
string configFile = "NHibernate.config";
Configuration config = NHibernateSession.Init(
new SimpleSessionStorage(),
mappingAssemblies,
new AutoPersistenceModelGenerator().Generate(),
configFile);


Regards
Dan

csetzkorn

unread,
Apr 6, 2010, 12:00:16 PM4/6/10
to S#arp Architecture
Thanks Dan. This worked fine.
Reply all
Reply to author
Forward
0 new messages