Web サイトに検索機能がありますが、失敗することがあります。C# / ASP.NET / WebForms でビルドされ、ActiveRecord を使用します。
基本的に、データベースの VIEW から返されるレコードが多すぎると、UPDATE エラーが発生します。
string query = "s";
Order[] orders = new order[] { Order.Asc("LastName") };
List<ICriterion> crit = new List<ICriterion>();
Crit.Add(Expression.Sql(String.Format("LastName" LIKE '%{0}%' OR FirstName LIKE '%{0}%'", query)));
var rv = ActiveRecordBase.FindAll(typeof(vMyView), orders, crit.ToArray())
検索するクエリとして「s」を使用すると、コードの上記の部分が FindAll コマンドで失敗します (ここで多くの結果が得られます)。しかし、「x」をクエリとして使用すると、魅力的に機能します。
私が得るエラーは次のとおりです。
View or function 'vAllowedVessels' is not updatable because the modification affects multiple base tables.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: View or function 'vAllowedVessels' is not updatable because the modification affects multiple base tables.
Source Error:
Line 74: List<ICriterion> crit = new List<ICriterion>();
Line 75: Crit.Add(Expression.Sql(String.Format("LastName" LIKE '%{0}%' OR FirstName LIKE '%{0}%'", query)));
Line 75: var rv = ActiveRecordBase.FindAll(typeof(vMyView), orders, crit.ToArray()) <--- This is highlighted in red!
Stack Trace:
[GenericADOException: could not update: [Ovf.Model.vAllowedVessels#3843][SQL: UPDATE vAllowedVessels SET FixtureId = ?, ContractDate = ?, No = ?, ContractForm = ?, VesselName = ?, Status = ?, CreatedDate = ?, Buyer = ?, BuyerName = ?, BuyerShortName = ?, BuyPrincipal = ?, BuyPrincipalName = ?, Seller = ?, SellerName = ?, SelPrincipal = ?, SelPrincipalName = ?, Operator = ?, Broker = ?, UsrCode = ? WHERE VesselFolderId = ?]]
NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) +2474
NHibernate.Persister.Entity.AbstractEntityPersister.UpdateOrInsert(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) +335
NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, Object rowId, ISessionImplementor session) +1898
NHibernate.Action.EntityUpdateAction.Execute() +764
NHibernate.Engine.ActionQueue.Execute(IExecutable executable) +48
NHibernate.Engine.ActionQueue.ExecuteActions(IList list) +128
NHibernate.Engine.ActionQueue.ExecuteActions() +50
NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) +215
NHibernate.Event.Default.DefaultAutoFlushEventListener.OnAutoFlush(AutoFlushEvent event) +225
NHibernate.Impl.SessionImpl.AutoFlushIfRequired(ISet`1 querySpaces) +288
NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results) +524
NHibernate.Impl.CriteriaImpl.List(IList results) +76
NHibernate.Impl.CriteriaImpl.List() +71
Castle.ActiveRecord.ActiveRecordBase.FindAll(Type targetType, Order[] orders, ICriterion[] criteria) in c:\TeamCity\buildAgent\work\e41ee5ead2eba140\src\Castle.ActiveRecord\Framework\ActiveRecordBase.cs:1034
[ActiveRecordException: Could not perform FindAll for vAllowedVessels]
Castle.ActiveRecord.ActiveRecordBase.FindAll(Type targetType, Order[] orders, ICriterion[] criteria) in c:\TeamCity\buildAgent\work\e41ee5ead2eba140\src\Castle.ActiveRecord\Framework\ActiveRecordBase.cs:1046
Ovf.Model.vAllowedVessels.SearchByType(String query, String typename, String usrCode) in g:\Dev\2012\OnTrack\model\Profile\vAllowedVessels.cs:76
Search_Default.BindVesselFolders() in g:\Dev\2012\OnTrack\webapp\Search\Default.aspx.cs:155
Search_Default.ChangeStatus(Object sender, EventArgs e) in g:\Dev\2012\OnTrack\webapp\Search\Default.aspx.cs:145
System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e) +116
System.Web.UI.WebControls.DropDownList.RaisePostDataChangedEvent() +133
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent() +13
System.Web.UI.Page.RaiseChangedEvents() +132
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1644
私は何も更新したくないことに注意してください-ビューを照会するだけです。