执行多条件时出错,未知列 - Mono + NHibernate + MySQL

时间:2014-03-13 22:29:23

标签: c# mysql nhibernate mono

apache + mod_mono + mysql 下运行ASP.NET MVC应用程序 我收到这个错误:

MySql.Data.MySqlClient.MySqlException
Unknown column 'this_.date_created' in 'field list'

例外:

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开发机器上使用windows版本的mysql。

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;

可能导致此问题的原因是什么?

1 个答案:

答案 0 :(得分:0)

这件事发生在每个人身上。环境,库或MySQL没有错。 我的连接字符串指向旧版本的数据库。 的web.config

  <connectionStrings>
   <add name="localhost" connectionString="Server=name;Database=old_database_version;User id=user;Password=pass;"/>   
  </connectionStrings>

感谢大家的努力和时间。