ext:System.Exception:Sequence包含多个匹配元素

时间:2012-12-12 15:14:59

标签: asp.net extjs sqldatasource ext.net

为什么会发生这种错误?任何的想法 ?!

(我使用sqldatasource将数据从表单插入数据库)

我已设置ShowWarningOnFailure="true",错误窗口告诉我这个。

{
    serviceResponse: {
        success: false,
        message: "System.Exception: Sequence contains more than one matching element ---> System.InvalidOperationException: Sequence contains more than one matching element\r\n at System.Linq.Enumerable.Single[TSource](IEnumerable1 source, Func2 predicate)\r\n at Ext.Net.Store.InsertCallback(Int32 recordsAffected, Exception exception) in C:\Users\Geoffrey McGill\Documents\Visual Studio 2010\Projects\Ext.NET\v2\Ext.Net\Ext\Data\Store.cs:line 1053\r\n at System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback)\r\n at Ext.Net.Store.MakeInsertes(IDataSource ds, JArray data) in C:\Users\Geoffrey McGill\Documents\Visual Studio 2010\Projects\Ext.NET\v2\Ext.Net\Ext\Data\Store.cs:line 982\r\n at Ext.Net.Store.MakeChanges() in C:\Users\Geoffrey McGill\Documents\Visual Studio 2010\Projects\Ext.NET\v2\Ext.Net\Ext\Data\Store.cs:line 839\r\n at Ext.Net.Store.DoSaving(String action, String jsonData, JToken parameters) in C:\Users\Geoffrey McGill\Documents\Visual Studio 2010\Projects\Ext.NET\v2\Ext.Net\Ext\Data\Store.cs:line 793\r\n --- End of inner exception stack trace ---\r\n at Ext.Net.Store.DoSaving(String action, String jsonData, JToken parameters) in C:\Users\Geoffrey McGill\Documents\Visual Studio 2010\Projects\Ext.NET\v2\Ext.Net\Ext\Data\Store.cs:line 806\r\n at Ext.Net.Store.RaiseAjaxPostBackEvent(String eventArgument) in C:\Users\Geoffrey McGill\Documents\Visual Studio 2010\Projects\Ext.NET\v2\Ext.Net\Ext\Data\Store.cs:line 1131",
        data: 
    }
}

2 个答案:

答案 0 :(得分:0)

看起来问题是您在某处调用扩展方法Single(),并且您传递的谓词会导致多个匹配。 Single()只能返回一个实体,因此抛出异常。

答案 1 :(得分:0)

Store.c文件中没有System.Linq.Enumerable.Single调用。

因此,Ext.NET不应该产生这种异常。

插入新记录时是否会抛出此异常,对吗?

如果是,我会尝试按原样检查SqlDataSource的InsertCommand,即没有Ext.NET上下文。

还有一个问题,其中讨论了类似的例外情况 Sequence contains more than one element