Projection by expression where members are in base class throw exception

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Minor - P4
    • None
    • Affects Version/s: 2.0
    • Component/s: LINQ
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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
              Reporter:
              Kieren Johnstone
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: