Hi,
I have a class that has a readonly IEnumerable<> property. There is a backing field that contains the data. When I map the field and name is as the IEnumberable property, I am unable to perform Linq queries against my data. Am I doing something wrong? Quick and dirty example:
class Foo {
private IList<string> _bars = new List<string>();
public IEnumerable<string> Bars { get { return new ReadOnlyCollection<string>(_bars); } }
}
Mappings:
BsonClassMap.RegisterClassMap<Foo>(cm => {
cm.AutoMap();
cm.MapField("_bars").SetElementName("Bars");
});
And when I try and query it:
var collection = _database.GetCollection<Foo>("Foos");
var test = collection.AsQueryable().Any(f => f.Bars == "WTF!!");
I receive this lovely error:
"Class Foo does not have a member called Bars.
Parameter name: memberName"
I would very much expect this to work. It saves the data as expected. Is there a way to do this? If not, when will it be implemented?
Thanks!!