mongodb/mongo-csharp-driver — pull request #154 by ghorsey (2013-03-25 20:49:42+00:00)
Title: Fix to allow Linq queries against properties mapped to a private instance field

I think I found a missing use case:

1. Map a private instance collection variable, which backs a public read-only collection property
2. Use a linq query against the public read-only collection.

The problem here is that the class map's MemberName equals the instance variable name, and not the public property collection name..

The change here is that I am checking against both the class map's MemberName and Element name values.

This allows you to map an instance field and set the element name as the public property on the class. This seems to be enough to get the Linq queries to work (Although I'm not sure if there is a more elaborate way to achieve this functionality).

I know with something like FluentNHibernate, you map the public property, and set the backing field:
Map(x => x.Collection).Access.ReadOnlyPropertyThroughCamelCaseField();

This allows the same functionality if you map the field and set the Element name to be the name of the public property which will be used by Linq.

https://groups.google.com/forum/?fromgroups=#!topic/mongodb-csharp/hnumCgDD9-M