Empty string matches all strings in LINQ query

52 views
Skip to first unread message

AlexK

unread,
Sep 16, 2011, 9:22:34 AM9/16/11
to ravendb
Suppose you have added a bunch of Item objects to the DB and you want
to query by ID (which is a string). The following IDs exist in the DB:
1, 2, 3.

The following returns only items whose IDs are "2":
var items = session.Query<Item>().Where(x => x.Id == "2")

The following returns ALL items.
var items = session.Query<Item>().Where(x => x.Id == string.Empty)

Is this an intentional shortcut to get all items? How should I query
for string.Empty fields then?

I tried build 457 and 465 (latest stable as of writing) with client
for .Net 3.5.

Ayende Rahien

unread,
Sep 16, 2011, 10:23:57 AM9/16/11
to rav...@googlegroups.com
Alex,
That isn't intentional, but it does make sense. Due to the way we are actually search for things, a query on string.Empty is equal to querying for everything
fixed in the next build
Reply all
Reply to author
Forward
0 new messages