我有一个会员数据库。成员有电话号码列表。我正在尝试获取具有指定电话号码的所有成员。
public class Member {
...
public ObservableCollection<Phone> Phones { get; set; }
}
public class Phone {
public string Number { get; set; }
...
}
...
private IMongoCollection<Member> _members;
...
private List<Member> GetMembers(string phone) {
List<Member> list = _members.Find(
member => member.Phones.First(
p=>p.Number == phone).Number.Equals(phone)).ToList();
return list;
}
GetMembers
返回一个空列表(是的,字符串phone
与数据库中的成员匹配)。如何获得具有给定电话号码的会员名单?
IMongoCollection文档: http://api.mongodb.com/csharp/current/html/T_MongoDB_Driver_IMongoCollection_1.htm