arrays - et Return the Whole Subdocument Arrary from MongoDB -
i need of subdocuments array courses class user.userid = whatever , courses.status=active
public class user public property userid string 'this unique index this, unless think otherwise public property coursedata() list(of courses) ' public property groups list(of string) public property bu list(of string) end class public class courses public property id string 'this can dynamic public property description string public property completiondate string public property hours string public property status string end class
using vb.net , tried few ways, want courses returned have status="active" dumped ienumberable
i tried (_users collection of user) (_uid variable passed it)
return _users.findas(of user)(query.and(query.eq("learninghours.status", "active"), (query.eq("userid", _uid)))) return _users.findas(of user)(query.and(query.eq("learninghours.status", "active"), (query.eq("userid", _uid)))).setfields("courses", "1") return _users.findas(of courses)(query.and(query.eq("learninghours.status", "active"), (query.eq("userid", _uid)))) return _users.findas(of courses)(query.and(query.eq("learninghours.status", "active"), (query.eq("userid", _uid)))).setfields("courses", "1")
none seem work, come fields class user or both class user , class course, course fields blank
i trying linq.. works - returns 1 row result
dim uc = _u in _users.asqueryable(of user)() _u.userid = _userid _ select _ courseid = _u.courses.where(function(c) c.state = "submitted").select(function(c) c.courseid)(0), _ coursedescription = _u.courses.where(function(c) c.state = "submitted").select(function(c) c.coursedescription)(0)
seems easy enough do, cant it
got it, think on thinking it
once declare instance of class, can iterate through subdocument
dim _u new user each c in _user.courses.where(function(cs) cs.status= "active").select(function(cs) cs) console.writeline(c.id & c.description & "so on...") next
Comments
Post a Comment