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

Projection by expression where members are in base class throw exception

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.0
    • Component/s: Linq
    • None

      The following throws an exception in BsonClassMap, in one of the internal checks:

      public class SomeBaseType
      {
      public int X

      {get; set;}
      }

      public class MyType : SomeBaseType
      {
      public int Y {get; set;}

      }

      _collection.AsQueryable().Select(collType => new MyType

      { Y = collType.SomeField; }

      );

      Basically, if the projection expression attempts to populate a member not directly in the type being constructed.

      I will update this issue with more complete code and if possible a PR - just wanted to log it down before I forget.!

            Assignee:
            Unassigned Unassigned
            Reporter:
            kierenj Kieren Johnstone
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: