Details
-
Task
-
Resolution: Done
-
Minor - P4
-
1.3.1
-
None
-
None
-
Minor Change
Description
When SetIdMember is called with a memberMap argument that is for a different class the current error message is too cryptic.
This can be reproduced using these classes:
public class B
|
{
|
public ObjectId Id;
|
public int b;
|
}
|
|
|
public class C : B
|
{
|
public int c;
|
}
|
and this code:
BsonClassMap.RegisterClassMap<C>(cm =>
|
{
|
cm.AutoMap();
|
cm.SetIdMember(cm.GetMemberMap(c => c.Id)); // wrong: Id is in class B, not class C
|
});
|
The call to SetIdMember is incorrect because it is being called when registering class C but Id is defined in class B. SetIdMember should have been called when registering class B instead.
The current error message "Invalid memberMap." is too cryptic. A better error message would provide more of an explanation of what is wrong.
Attachments
Issue Links
- is related to
-
CSHARP-396 BsonClassMap.AutoMap() does not incorporate inheritance.
-
- Closed
-
- related to
-
CSHARP-398 Can't Map Base Class Field As Id
-
- Closed
-