Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't this short circuit in lambda working?

Why linq is trying to check second expression anyway?

.Where(t =>  String.IsNullOrEmpty(someNullString) || t.SomeProperty >= Convert.ToDecimal(someNullstring))

What is usual workaround?

Update:
It is about LINQ to SQL, of course. It cannot translate to SQL.

like image 213
rudnev Avatar asked Jul 03 '09 14:07

rudnev


1 Answers

Is the .Where being used on a Table<>?

If so, then before any data can be grabbed, it must convert the LINQ to SQL and to do that it must convert the string into a decimal. It's not trying to actually perform the comparisons yet, it's trying to build the constructs necessary to retrieve data.

like image 186
Benjamin Autin Avatar answered Sep 22 '22 17:09

Benjamin Autin