我在我的应用程序中使用流利的 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 兼容性错误,请问我该如何解决这个问题?