1

Closed

Null reference exception when comparing with Guid.Empty

description

My problem is this: I have stash client and I want to do query like this:
var client = new StashClient<Subscription>(acountKey);
var query = client.CreateQuery().Where(x => x.Id == Guid.Empty).ToList();
I get Null reference exception on the second line:
Object reference not set to an instance of an object.
   at CodeSuperior.Lucifure.ExpressionParser`1.visitMemberAccess(MemberExpression exp)
   at CodeSuperior.Lucifure.ExpressionParser`1.visitBinary(BinaryExpression exp)
   at <StartupCode$Lucifure-Stash>.$ExpressionParser.doSubExpression@334[a](ExpressionParser`1 this, ExpStatement expStmt, Expression exp)
   at <StartupCode$Lucifure-Stash>.$ExpressionParser.evalQuery@277[a](ExpressionParser`1 this, ExpStatement expStmt, Expression exp)
   at CodeSuperior.Lucifure.ExpressionParser`1..ctor(Expression exp)
   at CodeSuperior.Lucifure.QueryProvider.ExecuteGen[a](Expression exp)
   at CodeSuperior.Lucifure.Query`1.System-Collections-Generic-IEnumerable`1-GetEnumerator()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
The Id property is of type Guid. When I compare to any other non-empty Guid everything is fine. I think this is a bug. I can provide more information if needed.
Closed May 9, 2013 at 5:16 AM by hocho

comments

hocho wrote May 8, 2013 at 4:26 AM

Thanks!
Yes, that is a bug.
For now, use this as a work around while I go about fixing it.

var guidEmpty = Guid.Empty;

var query = client.CreateQuery().Where(x => x.Id == GuidEmpty).ToList();

hocho wrote May 8, 2013 at 4:28 AM

typo. should be

var guidEmpty = Guid.Empty;

var query = client.CreateQuery().Where(x => x.Id == guidEmpty).ToList();

huluvu21 wrote May 8, 2013 at 6:20 AM

thanks for the quick reaction and also for the workaround and the future fix!

wrote May 9, 2013 at 5:16 AM

Resolved with changeset 22107.

wrote May 16, 2013 at 6:57 AM