c# MongoDb filter on List<T>.Count -


let code speak ;-)

public class sampleobject {     public list<string> samplestrings {get;set;} } 

mongodb related code:

// filter on samplestrings.count < 5 var filter = builders<sampleobject>.filter.lt(so => so.samplestrings.count, 5) 

unhandled exception: system.invalidoperationexception: unable determine serialization information so=> so.samplestrings.count.

count() won't work either. there mongodb way? maybe 1 integrates within ifluent interface?

try this:

var filter = builders<sampleobject>.filter.not(                       builders<sampleobject>.filter.exists(so => so.samplestrings[4])); 

this translated following mongo db filter query:

"samplestrings.4" : { "$exists" : false } 

saying the element @ index 4 should not exists equivalent the count of elements should less 5.


Comments