DB4o Linq query - How to check for null strings

Posted by Dave on Stack Overflow See other posts from Stack Overflow or by Dave
Published on 2010-06-17T11:16:33Z Indexed on 2010/06/17 11:23 UTC
Read the original article Hit count: 292

Filed under:
|
|
|

Hey there - simple query:

var q = (from SomeObject o in container
    where 
 o.SomeInt > 8 
 && o.SomeString != null //Null Ref here
    select o;

I always get a null reference exception.

If I use String.IsNullOrEmpty(o.SomeString) the query takes about 100 times as long, as if I use && o.SomeString != "" (which is way faster, but obviously not correct).

I'm guessing because DB4o needs to activate the objects, in order to pass them in to the IsNullOrEmpty call, and can't use the indexes.

My question is, what's a better way to check for nulls in this situation? Is there something like: mystring != Db4o.DBNull.Value, or something?

Cheers, Dave

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about string