Im与MongoDB官方司机(10人)合作。 我不能质疑莫奥果非行。 我有以下班子:
public class UserData
{
private ObjectId id;
public ObjectId _id
{
get { return id; }
set { id = value; }
}
[BsonElement("Mail")]
public string Email { get; set; }
public string Name{ get; set; }
}
public class UserSettings
{
private ObjectId id;
public ObjectId _id
{
get { return id; }
set { id = value; }
}
[BsonElement("usr")]
public MongoDBRef User { get; set; }
public List<SettingsUser> Settings{ get; set; }
}
I want to make a query that having the UserData I fetch the UserSettings of that user. I try the following but it does not work:
var colletion = db.GetCollection<UserSettings>("UsrSettings");
collection.Find(Query.EQ("usr", usr._id);
我也试图这样做:
collection.Find(Query.EQ("usr", new MongoDBRef("UsrSettings", usr._id));
但由于MongoDBRef不是BsonValue,它没有汇编。
另一项尝试:
collection.FindOne(Query.EQ("usr.$id", User._id));
我例外: 未预见的元件。
任何想法? 还是工作? 感谢!