Wednesday, 15 April 2015

c# - Can't use Linq with nested class List on MongoDb -



c# - Can't use Linq with nested class List<string> on MongoDb -

very similar this question, reply provided not solve case.

i have next class

public class company { [bsonid] public string dealerid = null; public list<string> dealers = new list<string>(); }

i trying query next query

collection.asqueryable<company>() .where(cpy => cpy.dealers.where(dlr => dlr.tolower.contains("dealer1")).any());

doing results in following

unable determine serialization info expression: enumerable.where(cpy.dealers, (string dlr) => dlr.tolower().contains("dealer1"))

i believe possible create wrapper around string , utilize predicate that's not elegant solution. there simple way of doing have missed?

i using mongodb 2.6.4 c# driver 1.9.2

edit:

i want above linq query converted either of next native mongo queries,

db.company.find({dealers: {$regex: /dealer1/, $options: "is"}})

or using elemmatch

db.company.find({dealers: {$elemmatch: { $regex: /dealer1/, $options: "is"}}})

c# linq mongodb

No comments:

Post a Comment