ZVenue
ZVenue

Reputation: 5027

LINQ query RavenDB

I have JSON documents in RavenDB that are in this format.

{
"Privilege": [
   {
    "Level": "Gold",
    "Code": "12312",
    "EndDate": "12/12/2012"
  }
 ],
   Phones": [
  {
    "Cell": "123123",
    "Home": "9783041284",
    "Office": "1234123412"
}
 ]
{

How can I write a LINQ query to write an Index.. that pulls all docs that have Privilege array as null or empty.

this is what I started writing out.. but need help.

from patrons in docs.Patrons
select new {patrons}
where patrons.Privilege == null;

Upvotes: 2

Views: 277

Answers (1)

synhershko
synhershko

Reputation: 4492

In an index:

from patrons in docs.Patrons
where patrons.Privilege == null
select patrons;

As a query:

from patrons in session.Query<Patron>()
where patrons.Privilege == null
select patrons;

Upvotes: 4

Related Questions