c# - MongoDb Search in Document's Collection returns only fully matched result - Why? -


i'm trying locate user username , password match. have office collection each office document contains many users

var builder = builders<mnoffice>.filter;              var filter = builder.anyeq(o => o.users, new officeuser()             {                 username = username,                 password = password             });             var office = await offices.find(filter).firstordefaultasync().configureawait(false);             return office; 

the above query returns null. although should result back. officeuser class has 3 properties, username, password, , name. mongo forces me 3 properties match in query, want have 2 properties matching (usename , password) in order result back, how can accomplish that? no documentation that.

thanks!

 var filter = builder.elemmatch(o => o.users, user => user.username == username && user.password == password); 

solved using elemmatch, still dont understand logic behind first attempt.


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -