Getting the exception on this line:
public bool isEngageOn() { line 149 -> return chatUserRepository.Table.Where(c => c.TrackingOn).Any(); }
TrackingOn is of type boolean.
.Any () assumes "Determine the weather, the sequence contains any elements", so why the exception "System.InvalidOperationException Sequence does not contain elements" caught on Elmah?
Error:
System.InvalidOperationException: Sequence contains no elements at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source) at System.Linq.Queryable.Any[TSource](IQueryable`1 source) at sf2015.Models.DomainModels.Services.ChatServices.isEngageOn() in C:\....\ChatServices.cs:line 149
ps: Cannot reproduce the error, but sometimes appears in Elmah error logs .
Below is the code for the repository
public virtual IQueryable<T> Table { get { return this.Entities; } } private DbSet<T> Entities { get { if (_entities == null) _entities = Context.Set<T>(); return _entities; } }
source share