ArgumentException with ?: operator
Posted: Tue 10 Aug 2010 08:26
We are start move our product from dotConnect for PostgreSQL 4.65 to 4.95.152. And this LINQ to SQL is worked in 4.65, but throw ArgumentException in 4.95.152:
Variables nullstatus and statusesIn - is boolean variables. They are become true or false with some conditions. statuses - is a int?[] array.
Exception is throw when statuses is an empty array (not null, but int?[0]). If I remove first part of condition and rewrite LINQ like this:
the query will execute in any cases.
Please, look at this point and tell me if any fixes is available...
Code: Select all
var query = from tr in context.Table
where tr.Status == (nullstatus ? null : new int?(-1)) || statuses.Contains(tr.Status) == statusesIn
select tr;
Exception is throw when statuses is an empty array (not null, but int?[0]). If I remove first part of condition and rewrite LINQ like this:
Code: Select all
var query = from tr in context.Table
where statuses.Contains(tr.Status) == statusesIn
select tr;
Please, look at this point and tell me if any fixes is available...