-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.0
-
Component/s: Serialization
-
None
-
Environment:Win8.1
Given the class and enum:
class Person { public Color FavoriteColor { get; set; } } enum Color { Blue, SomethingElse }
The following code snippet will not work:
Builders<Person>.IndexKeys.Ascending(x => x.FavoriteColor);
Builders<Person>.Filter.Eq(x => x.FavoriteColor, Color.Blue);
// other builders as well
Workaround
Use the string field name of the member. Even if you have mapped it to a different element name, as long as the member name is used, it will still get mapped:
Builders<Person>.IndexKeys.Ascending("FavoriteColor");
- related to
-
CSHARP-1268 SortBy exception with enum property type
- Closed