"Sequence contains more than one element" Error

I got Issues…
While closing Work Period and also while making changes inside Cash Management (typing values inside Remove Float, Entering Final Cash Value, Entering Final Card Value, Enter Cash Lift) , I got error message that says “Sequence contains more than on element” .It would really be Helpful If someone could help me with this issue.

THE BELOW ONE SHOWS DETAILED ERROR REPORT

[General Info]

Application: SambaPOS
Version: 5.3.7
Region: en
DB: SQ
Date: 4/1/2022
Time: 10:43 AM

[Exception Info 1]

Top-level Exception
Type: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
Stack Trace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Inner Exception 1
Type: System.InvalidOperationException
Message: Sequence contains more than one element
Source: System.Core
Stack Trace: at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source) at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<>c__141.b__14_2(IEnumerable1 sequence) at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable1 query, Expression queryRoot)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable1 source) at Samba.Infrastructure.Data.SqlData.EFWorkspace.Single[T](Expression1 expression, Expression1[] includes) at Samba.Services.Implementations.SettingsModule.ProgramSettings.GetSetting(String valueName) in C:\Users\Vehbi\Documents\Source\Repos\sambapos-v5-pro\Samba.Services\Implementations\SettingsModule\ProgramSettings.cs:line 0 at Samba.Services.Implementations.SettingsModule.SettingService.ReadGlobalSetting(String settingName) in C:\Users\Vehbi\Documents\Source\Repos\sambapos-v5-pro\Samba.Services\Implementations\SettingsModule\SettingService.cs:line 102 at Samba.Presentation.ClientLibrary.Modules.SettingsModule.ActionProcessors.UpdateProgramSetting.UpdateSetting(ActionData actionData, String settingName, String updateType) in C:\Users\Vehbi\Documents\Source\Repos\sambapos-v5-pro\Samba.Presentation.ClientLibrary\Modules\SettingsModule\ActionProcessors\UpdateProgramSetting.cs:line 35 at Samba.Presentation.ClientLibrary.Modules.SettingsModule.ActionProcessors.UpdateProgramSetting.Process(ActionData actionData, RuleExecutionContext context) in C:\Users\Vehbi\Documents\Source\Repos\sambapos-v5-pro\Samba.Presentation.ClientLibrary\Modules\SettingsModule\ActionProcessors\UpdateProgramSetting.cs:line 26 at Samba.Services.Common.RuleActionTypeRegistry.ProcessAction(String actionType, ActionData actionData, RuleExecutionContext context) in C:\Users\Vehbi\Documents\Source\Repos\sambapos-v5-pro\Samba.Services\Common\RuleActionTypeRegistry.cs:line 39 at Samba.Services.Implementations.AutomationModule.AutomationService.ProcessAction(String actionType, ActionData actionData, RuleExecutionContext context) in C:\Users\Vehbi\Documents\Source\Repos\sambapos-v5-pro\Samba.Services\Implementations\AutomationModule\AutomationService.cs:line 42 at Samba.Services.Implementations.AutomationModule.ActionDataBuilder.<>c__DisplayClass13_0.<InvokeWith>b__0() in C:\Users\Vehbi\Documents\Source\Repos\sambapos-v5-pro\Samba.Services\Implementations\AutomationModule\ActionDataBuilder.cs:line 76 at System.Windows.Threading.Dispatcher.Invoke(Action callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout) at System.Windows.Threading.Dispatcher.Invoke(Action callback) at Samba.Services.Implementations.AutomationModule.ActionDataBuilder.InvokeWith(AppState appState, RuleExecutionContext context) in C:\Users\Vehbi\Documents\Source\Repos\sambapos-v5-pro\Samba.Services\Implementations\AutomationModule\ActionDataBuilder.cs:line 84 at Samba.Services.Implementations.AutomationModule.RuleExecutor.ExecuteWithoutLogging(Object ruleData) in C:\Users\Vehbi\Documents\Source\Repos\sambapos-v5-pro\Samba.Services\Implementations\AutomationModule\RuleExecutor.cs:line 125 at Samba.Services.Implementations.AutomationModule.RuleExecutor.ExecuteWith(Object dataParameter) in C:\Users\Vehbi\Documents\Source\Repos\sambapos-v5-pro\Samba.Services\Implementations\AutomationModule\RuleExecutor.cs:line 62 at Samba.Services.Implementations.AutomationModule.NotificationService.NotifyEvent(String eventName, Object dataParameter, AppState appState) in C:\Users\Vehbi\Documents\Source\Repos\sambapos-v5-pro\Samba.Services\Implementations\AutomationModule\NotificationService.cs:line 26 at CallSite.Target(Closure , CallSite , INotificationService , String , Object , AppState ) at Samba.Services.Implementations.AutomationModule.CommandExecutionService.ExecuteAutomationCommand(AppState appState, String commandName, String commandValue, Object dataObject, Boolean background) in C:\Users\Vehbi\Documents\Source\Repos\sambapos-v5-pro\Samba.Services\Implementations\AutomationModule\CommandExecutionService.cs:line 78 at Samba.Presentation.ClientLibrary.Modules.AutomationModule.VisibleAutomationModule.<OnInitialization>b__6_3(EventParameters1 x) in C:\Users\Vehbi\Documents\Source\Repos\sambapos-v5-pro\Samba.Presentation.ClientLibrary\Modules\AutomationModule\VisibleAutomationModule.cs:line 67
at Microsoft.Practices.Prism.Events.EventSubscription1.InvokeAction(Action1 action, TPayload argument)
at Microsoft.Practices.Prism.Events.EventSubscription1.<>c__DisplayClass2.<GetExecutionStrategy>b__0(Object[] arguments) at Microsoft.Practices.Prism.Events.EventBase.InternalPublish(Object[] arguments) at Microsoft.Practices.Prism.Events.CompositePresentationEvent1.Publish(TPayload payload)
at Samba.Presentation.Services.Common.ExtensionMethods.Publish[TEventsubject](TEventsubject eventArgs, String eventTopic, Action expectedAction)


[Assembly Info]

mscorlib, Version=4.0.0.0
System, Version=4.0.0.0
Samba.Services, Version=5.3.8110.32796
Samba.Domain, Version=5.3.8110.32794
Samba.Infrastructure.Data, Version=5.3.8110.32794
System.ComponentModel.Composition, Version=4.0.0.0
Samba.Presentation.Services, Version=5.3.8110.32802
System.Core, Version=4.0.0.0
PresentationCore, Version=4.0.0.0
WindowsBase, Version=4.0.0.0
PresentationFramework, Version=4.0.0.0
DevExpress.Xpf.LayoutControl.v17.2, Version=17.2.13.0
System.Xml, Version=4.0.0.0
DevExpress.Xpf.Grid.v17.2, Version=17.2.13.0
DevExpress.Xpf.Grid.v17.2.Core, Version=17.2.13.0
System.Xaml, Version=4.0.0.0
Samba.Infrastructure, Version=5.3.8110.32789
Microsoft.Practices.Prism, Version=4.0.0.0
System.Runtime.Serialization, Version=4.0.0.0
Microsoft.Practices.Prism.MefExtensions, Version=4.0.0.0
DevExpress.Xpf.Core.v17.2, Version=17.2.13.0
System.Windows.Forms, Version=4.0.0.0
System.Drawing, Version=4.0.0.0
Samba.Persistance, Version=5.3.8110.32795
Stateless, Version=1.0.0.0
PropertyTools, Version=2012.4.14.1
Samba.Localization, Version=5.3.8110.32791
ReachFramework, Version=4.0.0.0
EntityFramework, Version=6.0.0.0
FluentValidation, Version=3.4.0.0
NCalc, Version=1.3.8.0
Microsoft.CSharp, Version=4.0.0.0
Omu.ValueInjecter, Version=2.3.0.0
Microsoft.Practices.ServiceLocation, Version=1.0.0.0
DevExpress.Data.v17.2, Version=17.2.13.0
WindowsInput, Version=1.0.4.0



Looks like you might have a duplicate setting.

run this in SSMS to see if any results are returned:


SELECT Name,
       COUNT(*) AS Count
FROM dbo.ProgramSettingValues
GROUP BY Name
HAVING COUNT(Name) > 1;

If you see results, that will tell you which setting(s) is/are duplicated and you can determine which one needs to be removed.

1 Like

@Memo

I did get the result as the one mentioned below

Card Takings 2
Cash Lift 2
Cash Takings 2
Float Out 2

So something has created duplicate program settings; this shouldn’t happen when using automation to create/update a setting.

For your till close out, are you using actions to set the setting or are you using SQL?

In the meantime the following SQL query will leave only one matching program setting of the duplicates.

As usual, perform a backup. Seeing as this is for your till count, I would recommend executing this outside business hours.

WITH CTE (Name, Count)
AS (SELECT Name,
           ROW_NUMBER() OVER (PARTITION BY Name ORDER BY Id) AS Count
    FROM dbo.ProgramSettingValues)
DELETE FROM CTE
WHERE Count > 1;
2 Likes

Okay, I thinks its done ,Thanks for your Help