Project not working (neither builder version, neither Linq) MongoDB.Driver 2.19.0

Hello. I have never worked with complex projections before, so I decided to fill in the blanks and try to understand what methods of projections there are and how they work in the c# Driver. So, can anyone explain me where I’m wrong?

In a nutshell:

  1. how to project one data model (class) onto another using the c# mongodb driver (preferable using linq expression), when the properties of these models have different names and some of them have to be configured using c# code?
Project A to B when:
B.State = A.InitialState; //different preperty names
B.Name = $"{A.FirstName} some text".ToUpper(); // .ToUpper() method
  1. Can I somehow use such code in my project and what are the preconditions?
B b = await _collection.AsQueryable()
            .Select(a => new B(a))
  1. What is the best practices for projection using MongoDb.driver for c#?

Here is more detailed example of mine:

I’m using sample_airbnb.listingsAndReviews collection from Atlas Sample Dataset.

My c# entities looks like this:

internal class AirbnbEntity
    public string Id { get; set; }

    public string Name { get; set; }

    public int Accomodates { get; set; }

    public int Bedrooms { get; set; }

    public int ReviewsCount { get; set; }

    public string[] Amenities { get; set; }


    public decimal Price { get; set; }

    public Address Address { get; set; }

internal class Address
    public string Street { get; set; }

    public string Country { get; set; }

    public string CountryCode { get; set; }

Here’s an examples of projections that don’t work for me:

The A class was created for an example when you want to assign a bunch of properties of the source model to the projection model.

I was trying to do it by creating an object with an empty constructor and assigning fields, but in that case MongoDB.Driver.Linq.ExpressionNotSupportedException happened. So I tried to find workaround and use specific constructor new A(AirbnbEntity item):

public class A
        public A(AirbnbEntity item)
            Name = item.Name;
            Location = item.Address.CountryCode + " : " + item.Address.Country;
            Price = item.Price;
            PriceForWeek = item.Price * 7;
            Info = "Number of bedrooms: " + item.Bedrooms;
            StreetUpperCase = item.Address.Street.ToUpper();
            UpperCase2 = $"{item.Address.Street.ToUpper()}";

        //public AirbnbEntity Item { get; set; } //it works after this property is added
        public string Name { get; init; }
        public decimal Price { get; init; }
        public string Location { get; set; }
        public decimal PriceForWeek { get; set; }
        public string Info { get; set; }
        public string StreetUpperCase { get; set; }
        public string UpperCase2 { get; set; }

I call this method:

var personProjection = await _collection
            .Select(item => new A(item))

But in that case I got this exception:

MongoDB.Bson.BsonSerializationException: 'Creator map for class AggregationFramework.ProjectionStage+A has 1 arguments, but none are configured.'

The problem is resolved as soon as I add the public AirbnbEntity Item { get; set; } property to the A class model, but it looks strange for me, i don’t want to my A class has AirbnbEntity inside.