我有一個設置,我有一個表,有兩個字段,FirstName和LastName。爲了在名稱中進行搜索,我制定了一個包含FirstName + " " + Lastname
的公式。NHibernate標準和公式
但是,如果我嘗試做如下聲明:
Restrictions.InsensitiveLike("empl.FullNameFormula", "% " + restriction.PersonName + " %")
我收到的錯誤:
「過期超時操作或服務器完成前經過的超時時間沒有響應。 「。
但是,如果我嘗試做的,而不是像它的工作原理相同:
Restrictions.Eq("empl.FullNameFormula", "% " + restriction.PersonName + " %")
是否有與式,並試圖做這樣一個敏感的錯誤?
我使用的是NHibernate版本2.1.2.4000。
更新: 我的堆棧跟蹤看起來是這樣的:
[SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1951450
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849003
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2394
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +33
System.Data.SqlClient.SqlDataReader.get_MetaData() +83
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +297
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +141
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +12
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader() +12
NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd) +216
NHibernate.Impl.MultiCriteriaImpl.GetResultsFromDatabase(IList results) +310
NHibernate.Impl.MultiCriteriaImpl.List() +348
NHibernate.Impl.FutureCriteriaBatch.GetResultsFrom(IMultiCriteria multiApproach) +10
NHibernate.Impl.FutureBatch`2.GetResults() +88
NHibernate.Impl.FutureBatch`2.get_Results() +16
NHibernate.Impl.FutureBatch`2.GetCurrentResult(Int32 currentIndex) +52
NHibernate.Impl.<>c__DisplayClass4`1.<GetEnumerator>b__3() +53
NHibernate.Impl.<get_Enumerable>d__0.MoveNext() +73
System.Linq.Buffer`1..ctor(IEnumerable`1 source) +259
System.Linq.Enumerable.ToArray(IEnumerable`1 source) +81
xxx.DataAccess.PublicationRepository.Search(PublicationQuery restriction) in xxxx :197
layouts_www_xxx.RunSearch() in xxx:100
layouts_www_xxx.OnInit(EventArgs e) in xxxx :39
System.Web.UI.Control.InitRecursive(Control namingContainer) +333
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +378
什麼是生成的第一條語句的SQL,我會發現這一點,然後對數據庫運行它來追蹤您的問題。我懷疑這裏有一個數據庫問題。 – Rippo 2011-02-08 11:18:13
也說明了這個片段在這個片段上執行的總數rownum – Jaguar 2011-02-08 11:20:39
@Jaguar:它將在成千上萬的行上執行,所以沒有什麼大的。 – Dofs 2011-02-08 13:08:38