1

我正在 C# 中使用 NoRM 尝试 MongoDB,但无法弄清楚为什么我的 LINQ 查询不起作用。像这样简单的事情:

这如何返回填充了所有字段/属性的所有文档:

    return Collection.FindAll().Documents.ToList(); 

但是这个只返回正确数量的文档,并且只填充了 ID 字段?对象的其余部分是空的/空值?

    return Collection.Linq().ToList(); 

以下是集合的定义方式:

    public IMongoCollection<T> Collection 
    { 
        get { return _database.GetCollection<T>(); } 
    } 
4

1 回答 1

0

Where does the Linq method come from? If you want to return all items in the collection into a List, one of the two following options should work...

return Collection.AsQueryable().ToList();

return Collection.Find().ToList();
于 2010-08-02T15:52:13.997 回答