linq - Find documents that DON'T have a string in a collection -


i have entity following:

class person {     public icollection<string> optout { get; set; }     //other fields } 

my application allows user create dynamic mailing lists based on well-known set of fields in person.

the customers should able opt out of different mailing lists, optout might contain [ "marketing", "financial" ].

the query specific mailing list aggregates filter expressions (using queryable.where) , ravendb creates needed indexes without problems.

i have been reading, , seems neither of these constructs supported:

people.where(x => !x.optout.contains(mailinglisttype)); people.where(x => !x.optout.any(o => o == mailinglisttype)); people.where(x => x.optout.all(o => o != mailinglisttype)); 

how can create right query?

you need create index type of query.

in index should flatten optout collection can create queries on it.

more on here:

how query items nested collections in raven db?

edit

it seems can answered simple lucenequery w/o having explicitly create , index.

var users = session.advanced                    .lucenequery<person>()                    .where("optout:* , -optout:" + newslettertype)                    .tolist(); 

edit 2

you need create index:

from doc in docs.people select new { optout = doc.optout.count==0 ? "" : doc.optout} 

to include person documents having no optout values.

it frustrating how not available in query (typed client) can continue discussion on mailing list.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -