This project has moved and is read-only. For the latest updates, please go here.

MongoRepository.All() Does Not Allow Multiple Conditions

Apr 9, 2012 at 3:34 PM

I have a Class called 'Swine', that has a list of classes called 'Observations'.  Observation has a 'Name' (string) property.

When I use the following syntax, this will return all the 'Swine' object that have at least one Observation called 'Offtest'.

MongoRepository<Swine> repo;  (getting this through a custom class)

List<Swine> results = repo.All().Where(x=>x.Observations.Any(obs=>obs.Name == "Offtest").ToList();

--return valid list

When I try to use multiple conditions, this always returns 0 (zero), like this example:

List<Swine> results = repo.All().Where(x=>x.Observations.Any(obs=>obs.Name == "Offtest" || obs.Name =="Ontest").ToList();

--returns 0 (zero).

Is this something that is not implemented?


Apr 10, 2012 at 9:08 AM
Edited Apr 10, 2012 at 9:08 AM

As far as I know this is due to lack of support in FluentMongo. The upcoming release drops the FluentMongo dependency alltogether because the native 1.4+ driver supports Linq natively and if I'm not mistaken it should support .Any(). I haven't come around to testing this and I'm waiting for the 1.4.1 driver because 1.4.0 still has some serious Linq issues.

Apr 13, 2012 at 5:53 PM
Edited Apr 13, 2012 at 5:54 PM

For future reference: here are the (soon to be) supported Linq query operators and where clauses.