Wrong evaluation of && and || operator in LINQ queri
Posted: Tue 26 May 2009 10:14
Hello
I am using the || (OR) operator in the where clause of a LINQ statement. If the first oparand evaluates to true, the second operand shouldn't be evaluated as in the following example...
within this LINQ statement this rule does not work anymore... the second operand is evaluated anyway and throws an exception...
Can you confirm, this is a bug?
Best regards
________
Subaru R1 Specifications
I am using the || (OR) operator in the where clause of a LINQ statement. If the first oparand evaluates to true, the second operand shouldn't be evaluated as in the following example...
Code: Select all
string searchString = null;
if (true || "test".Contains(searchString))
searchString = "";
Code: Select all
string searchString = null;
var recordSet = (from m in PPCustomer.Mailings
where String.IsNullOrEmpty(searchString) || m.Subject.Contains(searchString)
select m);
Best regards
________
Subaru R1 Specifications