我正在使用 Visual Estudio 2010 c#、nhibernate queryover、silverlight 5 开发我的应用程序,在这部分中,我使用的数据访问部分都可以正常工作:
using (var session = NHibernateFactory.OpenSession())
{
ClassAlias ca = null;
var x = session.QueryOver<SomeClass>()
.Where(root=>root.SomeField > somefield)
.SelectList(list=>list
.Select(root=>root.SomeField1).WithAlias(()=>ca.SF1)
...
.Select(root=>root.SomeFieldN).WithAlias(()=>ca.SF2)
)
.UnderlyingCriteria.SetResultTransformer(
Transformers.AdvanceEntityMapTransformer<ClassAlias>())
.List<ClassAlias>();
}
所有的数据访问都是 select 语句,所以问题是当我使用 mono 将我的应用程序发布到 linux 环境时,我开始得到这个间歇性错误:
16:51:45.488 [Threadpool worker] ERROR NHibernate.Transaction.AdoTransaction - Begin transaction failed
System.NotImplementedException: The requested feature is not implemented.
at MySql.Data.MySqlClient.MySqlConnection.EnlistTransaction (System.Transactions.Transaction transaction) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000] in <filename unknown>:0
at NHibernate.Connection.DriverConnectionProvider.GetConnection () [0x00000] in <filename unknown>:0
此日志来自 nhibernate 通用日志文件,认为我找不到修复它的人,任何帮助都会非常受欢迎
我添加了一个自定义日志来捕获异常,并确保 nhibernate 中的这个异常是我的查询失败的原因,就是这种情况,这就是异常:
ERROR serverAppLog - custom error message
NHibernate.Exceptions.GenericADOException: could not execute query
[ SELECT this_.list_id as y0_, this_.list_name as y1_ FROM vicidial_lists this_ ]
[SQL: SELECT this_.list_id as y0_, this_.list_name as y1_ FROM vicidial_lists this_] ---> System.NotImplementedException: The requested feature is not implemented.
at MySql.Data.MySqlClient.MySqlConnection.EnlistTransaction (System.Transactions.Transaction transaction) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000] in <filename unknown>:0
at NHibernate.Connection.DriverConnectionProvider.GetConnection () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at NHibernate.Loader.Loader.DoList (ISessionImplementor session, NHibernate.Engine.QueryParameters queryParameters) [0x00000] in <filename unknown>:0
at NHibernate.Loader.Loader.ListIgnoreQueryCache (ISessionImplementor session, NHibernate.Engine.QueryParameters queryParameters) [0x00000] in <filename unknown>:$
at NHibernate.Loader.Loader.List (ISessionImplementor session, NHibernate.Engine.QueryParameters queryParameters, ISet`1 querySpaces, NHibernate.Type.IType[] resu$
at NHibernate.Loader.Criteria.CriteriaLoader.List (ISessionImplementor session) [0x00000] in <filename unknown>:0
at NHibernate.Impl.SessionImpl.List (NHibernate.Impl.CriteriaImpl criteria, IList results) [0x00000] in <filename unknown>:0