IQueryable.Single() should throw when no items (bug?)

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
edwin
Posts: 19
Joined: Thu 08 Oct 2009 09:15

IQueryable.Single() should throw when no items (bug?)

Post by edwin » Thu 08 Oct 2009 09:28

Hello all,

I have the following example code giving me a headache:

IQueryable q1 = context.ImportDefinitions
.Where(x => x.Code.ToUpper() == table.ToUpper()
&& Utilities.DateUtility.GetToday() >= x.BeginDate
&& Utilities.DateUtility.GetToday() <= x.EndDate);

var x1 = q1.Single(); // NO exception thrown, but x1 == null

var x2 = q1.ToList();
var x3 = x2.Single(); // Exception is thrown here!

q1.Single() should throw an exception an NEVER return NULL, like it does in the above example. When I do q1.ToList() and then call .Single() on it, the exception is thrown like it should.

Because in the latter case, the exception is thrown and in the first case it isn't, I suspect it's a problem with DevArt.

Can anyone confirm this and/or does anyone have a solution?

Kind regards,

Edwin.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 09 Oct 2009 13:09

Thank you for the report, we have reproduced the problem.
I will let you know as soon as it is fixed.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 13 Oct 2009 07:42

Thank you for your help, we have fixed the problem. The fix will be included in the nearest build.

Post Reply