fluent-mongo icon indicating copy to clipboard operation
fluent-mongo copied to clipboard

Any still not working

Open baio opened this issue 13 years ago • 1 comments

Hi ! I already have seen similar problem (see issue #2 - closed), but I can't find some resolution. Help please!

MongoCollection<Doc> coll = db.GetCollection<Doc>("xxx"); var items = coll.AsQueryable().Where(p => p.boundary != null).Where( p => p.boundary.Any(s => s == "zzz")). Select(p => new Doc { _id = p._id, strArray = p.strArray}).ToArray();

    [Serializable]
    public class Doc : IMongoQuery
    {
        public int _id { get; set; }

        public string [] strArray { get; set; }

    }

Exception :

QueryFailure flag was invalid parameter: expected an object ($elemMatch) (response was { "$err" : "invalid parameter: expected an object ($elemMatch)", "code" : 10065 }).

baio avatar Feb 13 '12 19:02 baio

Possibly related, I've found that nested expression in Any worked in 1.2.0 but is broken in 1.3.1.1.

Referring to $elemMatch documentation on the wiki, this would be an equivalent LINQ expression:

var people = collection.AsQueryable().Where(x => x.Addresses.Any(a => a.City == "Paris" && a.Country == "France"));

jberd126 avatar Feb 14 '12 15:02 jberd126