This project is read-only.
1
Vote

String.IsNullOrEmpty(" ") Returns True

description

VB.NET considers String.IsNullOrEmpty(" ") to be False however once the code is converted to SQL, it evaluates to True
Debug.Print(String.IsNullOrEmpty(" ").ToString())
' ==> False

Dim SpaceQry = DB.TheTable _
    .Where(Function(DbRow) String.IsNullOrEmpty(" "))

Debug.Print(SpaceQry.Count().ToString())
' ==> Same as SELECT COUNT(*) FROM TheTable
Resulting SQL
WHERE (N' ' IS NULL) OR (( CAST(LEN(N' ') AS int)) = 0)
The core of the issue is that CAST(LEN(N' ') AS int) Does = 0

comments