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

2.19.1 -> 2.19.2 FindExpressionProjectionDefinition Issue? Trying to select/project/cast

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.19.2
    • Component/s: None
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      I'm running into an issue when trying to update my project to from 2.19.1 to latest. I came across a change within 2.19.2 that is causing my code to break, and I'm curious a suggested approach to resolve or work-around. I've commented https://github.com/mongodb/mongo-csharp-driver/pull/1087#issuecomment-1816897272 my issue in further depth.

      • In 2.19.1, projection is public FindExpressionProjectionDefinition
      • In 2.19.2, projection is internal sealed ExpressionProjectionDefinition

      var projection = Builders<DocumentEntity>.Projection.Expression(x => new SelectEntity { Name = x.Name, Email = x.Email });

      I have a method that is supposed to run my projection using IQueryable via the code below, which no longer works with 2.19.2 and greater.

      if (projection is FindExpressionProjectionDefinition<TDocumentEntity, TSelectEntity> expSelect)

      Unknown macro: {     return queryable.Select(expSelect.Expression).Cast<TReturnEntity>().ToList(); }

      Please advise! Example project attached.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            connor.storer@kbx.com Connor Storer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: