简体   繁体   中英

ext : System.Exception: Sequence contains more than one matching element

Why is this error happening? Any idea ?!

(I insert data from a form to the database by using a sqldatasource)

I've set the ShowWarningOnFailure="true" and the error window tells me this.

{
    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: 
    }
}

Looks like the problem is that you are calling the extension method Single() somewhere, and the predicate you are passing results in more than one match. Single() can only return one entity, so it throws an exception.

There is no System.Linq.Enumerable.Single call in the Store.c file.

So, Ext.NET should not produce this exception.

Is this exception thrown on inserting a new record, right?

If yes I would try to check the SqlDataSource's InsertCommand as it is, ie without an Ext.NET context.

Also there is a question where a similar exception was discussed.
Sequence contains more than one element

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM