Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-708

BsonClassMap.SetIdMember fails for lhamda expressions that contain interface members

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Blocker - P1 Blocker - P1
    • None
    • Affects Version/s: 1.8
    • Component/s: None
    • Environment:
      Windows 8, MongoDB 2.4
    • Fully Compatible

      We upgrade to the 1.8 driver via NuGet this morning and instantly brought down our dev environment.

      Here is part of the stack trace:

      at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
      at MongoDB.Bson.Serialization.BsonClassMap`1.ResolveExplicitProperty(MemberInfo interfaceMemberInfo, Type targetType)
      at MongoDB.Bson.Serialization.BsonClassMap`1.GetMemberInfoFromLambda[TMember](Expression`1 memberLambda)
      at MongoDB.Bson.Serialization.BsonClassMap`1.GetMemberNameFromLambda[TMember](Expression`1 memberLambda)

      Here is some snippets that will show how to reproduce:

      protected override void ConfigureClassMap(BsonClassMap<T> cm) {
      cm.SetIdMember(cm.GetMemberMap(c => c.Id).SetRepresentation(BsonType.ObjectId));
      }

      ..
      where T : class, IIdentity, new() {
      ..

      public interface IIdentity {
      string Id

      { get; }

      }

      ..

      public class JobHistory : IIdentity {
      public string Id

      { get; set; }

      }
      ..

            Assignee:
            craig.wilson@mongodb.com Craig Wilson
            Reporter:
            bniemyjski Blake Niemyjski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: