views:

85

answers:

1

I'm trying MongoDB with NoRM in C# and can't figure out why my LINQ queries don't work. Something as simple as this:

How can this return all documents with all the fields/properties populated:

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

but this one only returns the correct number of documents with only the ID field populated? The rest of the object are empty/nulls?

    return Collection.Linq().ToList(); 

Here is how collection is defined:

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

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();
John Zablocki