在apache + mod_mono + mysql下运行ASP.NET MVC应用程序 我收到此错误:
MySql.Data.MySqlClient.MySqlException
Unknown column 'this_.date_created' in 'field list'
异常(exception):
NHibernate.HibernateException: Error executing multi criteria : [SELECT count(*) as y0_ FROM tag this_;
SELECT this_.id as id4_0_, this_.name as name4_0_, this_.description as descript3_4_0_, this_.date_created as date4_4_0_, this_.total_peruns as total5_4_0_, this_.user_id as user6_4_0_ FROM tag this_ ORDER BY this_.total_peruns desc limit ?p0;
] ---> MySql.Data.MySqlClient.MySqlException: Unknown column 'this_.date_created' in 'field list'
at MySql.Data.MySqlClient.MySqlStream.ReadPacket () [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.NativeDriver.ReadResult () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at NHibernate.Impl.MultiCriteriaImpl.GetResultsFromDatabase (System.Collections.IList) <0x0097f>
at NHibernate.Impl.MultiCriteriaImpl.DoList () <0x0003f>
at NHibernate.Impl.MultiCriteriaImpl.ListIgnoreQueryCache () <0x0000f>
at NHibernate.Impl.MultiCriteriaImpl.List () <0x00297>
at NHibernate.Impl.FutureCriteriaBatch.GetResultsFrom (NHibernate.IMultiCriteria) <0x0001d>
at NHibernate.Impl.FutureBatch`2<NHibernate.ICriteria, NHibernate.IMultiCriteria>.GetResults () <0x00110>
at NHibernate.Impl.FutureBatch`2<NHibernate.ICriteria, NHibernate.IMultiCriteria>.get_Results () <0x0001f>
at NHibernate.Impl.FutureBatch`2<NHibernate.ICriteria, NHibernate.IMultiCriteria>.GetCurrentResult<perun.domain.model.entities.Tag> (int) <0x00027>
at NHibernate.Impl.FutureBatch`2/<>c__DisplayClass4`1<NHibernate.ICriteria, NHibernate.IMultiCriteria, perun.domain.model.entities.Tag>.<GetEnumerator>b__3 () <0x00043>
...
该表中存在 date_created 列。
相同的应用程序可以在我的带有 Windows 版本 mysql 的 Windows 开发机器上运行。
MySQL Linux: 5.5.34
MySQL Windows: 5.6.12
nHibernate version: 3.1.0.4000
生成的 SQL 在数据库中正确执行 (?p0 = 10):
SELECT this_.id as id4_0_, this_.name as name4_0_, this_.description as descript3_4_0_, this_.date_created as date4_4_0_, this_.total_peruns as total5_4_0_, this_.user_id as user6_4_0_ FROM tag this_ ORDER BY this_.total_peruns desc limit ?p0;
什么可能导致此问题?
最佳答案
这种事每个人都会遇到。环境、库或 MySQL 都没有问题。 我的连接字符串指向旧版本的数据库。 Web.config
<connectionStrings>
<add name="localhost" connectionString="Server=name;Database=old_database_version;User id=user;Password=pass;"/>
</connectionStrings>
感谢大家的努力和时间。
关于c# - 执行多条件时出错,未知列 - Mono + NHibernate + MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22392354/