【发布时间】:2013-09-29 20:25:52
【问题描述】:
我在我的应用程序中使用 fluent nhibernate,我还使用 sql server 2012。这是我的配置:
public class SessionFactory
{
private static ISessionFactory _sessionFactory;
public static string ConnectionString
{
get { return ConfigurationManager.ConnectionStrings["ECommerceConnectionString"].ToString(); }
}
private static void Initialize()
{
var config = Fluently.Configure().Database(
MsSqlConfiguration
.MsSql2008
.ConnectionString(ConnectionString).ShowSql().Dialect<MsSql2012Dialect>());
_sessionFactory = config.Mappings(m => m.FluentMappings.AddFromAssemblyOf<ContactMapping>()).BuildSessionFactory();
}
private static ISessionFactory GetSessionFactory()
{
if (_sessionFactory == null)
Initialize();
return _sessionFactory;
}
private static ISession GetNewSession()
{
return GetSessionFactory().OpenSession();
}
public static ISession GetCurrentSession()
{
var sessionStorageContainer = SessionStorageFactory.GetStorageContainer();
var currentSession = sessionStorageContainer.GetCurrentSession();
if (currentSession == null)
{
currentSession = GetNewSession();
sessionStorageContainer.Store(currentSession);
}
return currentSession;
}
}
虽然我正在使用MsSql2012Dialect,但我仍然遇到sql server 兼容性错误,请问我该如何解决?
【问题讨论】:
-
你能发布完整的例外吗? “无效的对象名称”看起来太笼统了
标签: nhibernate fluent-nhibernate