nhibernate会在每次有人发出请求时解析xml文件,或者每次应用程序启动时解析xml文件?nhibernate开始执行
那么这里就是即时通讯做:
public class SessionManager
{
private readonly ISessionFactory _sessionFactory;
public SessionManager()
{
_sessionFactory = GetSessionFactory();
}
public ISession GetSession()
{
return _sessionFactory.OpenSession();
}
private static ISessionFactory GetSessionFactory()
{
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005
.ConnectionString(c =>
c.Is(
@"Data Source=Pc-De-Yassir;Initial Catalog=MyDatabase;User Id=sa;Password=password;Integrated Security=True")
))
.Mappings(m =>
m.AutoMappings.Add
(
AutoPersistenceModel.MapEntitiesFromAssemblyOf<Model.Category>()
))
.BuildSessionFactory();
}
}
,这里是我如何从数据库中获取数据
public IList<Category> GetCategories()
{
var session = new SessionManager().GetSession();
return session.CreateCriteria(typeof(Category))
.List<Category>();}
所以我的问题是将NHibernate的配置本身第一次遇到这种运行的方法每次发出请求?
..这应该在应用程序启动时发生一次。 – 2009-06-25 10:54:30