一、Access数据库配置
NHibernate本身不支持Access数据库,一开始看网上各种文档,捣敲浪费了N分钟。还是祭起Nuget神器引用NHibernate.JetDrive。代码如下,搞定收工。。。
private string FilePath { get; set; }
private ISessionFactory BuildSessionFactory()
{
var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};", this.FilePath);
return Fluently.Configure()
.Database(JetDriverConfiguration.Standard
.ConnectionString(connectionString)
.Dialect<JetDialect>()
.Driver<JetDriver>())
.Mappings(p => p.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
.BuildSessionFactory();
}
时间: 2024-10-25 20:33:54