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

Projection by expression where members are in base class throw exception

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor - P4 Minor - P4
    • None
    • 2.0
    • Linq
    • None

    Description

      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.!

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: