Sequence contains no matching element

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
EJD
Posts: 2
Joined: Tue 07 Nov 2017 15:03

Sequence contains no matching element

Post by EJD » Tue 07 Nov 2017 15:46

This worked with v9.4.348 but now no longer works with v9.5.381

Code: Select all

var surveys = await Context.SURVEY_TYPES
.FilterByStartEndDate(submissionContext.DueDate)
.ToListAsync();

public static IQueryable<TEntity> FilterByStartEndDate<TEntity>(this IQueryable<TEntity> query, DateTime dueDate) where TEntity : IStartEndDate
{
     return query.Where(e => e.END_DATE == null || e.START_DATE <= dueDate && e.END_DATE >= dueDate);
}
Throws error:

Code: Select all

System.TypeInitializationException: The type initializer for 'DataAccess.Extensions.IQueryableExtensions' threw an exception. ---> System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
   at DataAccess.Extensions.IQueryableExtensions..cctor() in C:\Projects\1805.0\app\DataAccess\Extensions\IQueryableExtensions.cs:line 25
   --- End of inner exception stack trace ---
   at Onsis2.DataAccess.Extensions.IQueryableExtensions.FilterByStartEndDate[TEntity](IQueryable`1 query, DateTime dueDate)
   at Queries.Lookups.GetSurveyTypesQueryHandler.<Handle>d__9.MoveNext() in C:\Projects\1805.0\app\Queries\Lookups\GetSurveyTypesQueryHandler.cs:line 50

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: Sequence contains no matching element

Post by Shalex » Tue 07 Nov 2017 18:24

Please upload a small complete test project with the corresponding DDL/DML script to ftp://ftp.devart.com (credentials: anonymous / yourEmail). Also specify the version of your Oracle Server.

EJD
Posts: 2
Joined: Tue 07 Nov 2017 15:03

Re: Sequence contains no matching element

Post by EJD » Wed 08 Nov 2017 17:55

Ended up being toSQL causing the issue.

https://github.com/aspnet/EntityFramewo ... ssues/9414

We corrected the code and the issue is resolved.

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: Sequence contains no matching element

Post by Shalex » Thu 09 Nov 2017 09:26

Thank you for letting us know.

Post Reply