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
Post a Comment