MongoDb C# projection fails after upgrade to V3

I have just upgraded the Linqprovider for MongoDb C#driver to V3:

var clientSettings = MongoClientSettings.FromConnectionString(Configuration.GetConnectionString(MyConnectionString));
clientSettings.LinqProvider = **LinqProvider.V3**;

Mostly my queries work ok but there are several I am having problems with, like this one:

return await _myCollection.Find(model.GetFilter())
    .Project(x => new MyModel
    {
    Id = x.Id,
....
    FirstVideoTitle = x.Videos != null && x.Videos.Any() ? x.Videos.First().Title : "",
})

I have also tried x.Videos.Length > 0 which also fails with the following error message:

  Command find failed: Executor error during find command :: caused by :: The argument to $size must be an array, but was of type: missing.
  MongoDB.Driver.MongoCommandException: Command find failed: Executor error during find command :: caused by :: The argument to $size must be an array, but was of type: missing.
     at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ProcessResponse(ConnectionId connectionId, CommandMessage responseMessage)
     at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken)
     at MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocolAsync[TResult](IWireProtocol`1 protocol, ICoreSession session, CancellationToken cancellationToken)
     at MongoDB.Driver.Core.Operations.RetryableReadOperationExecutor.ExecuteAsync[TResult](IRetryableReadOperation`1 operation, RetryableReadContext context, CancellationToken cancellationToken)

     at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.ExecuteAsync(RetryableReadContext context, CancellationToken cancellationToken)
     at MongoDB.Driver.Core.Operations.FindOperation`1.ExecuteAsync(RetryableReadContext context, CancellationToken cancellationToken)
     at MongoDB.Driver.Core.Operations.FindOperation`1.ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken)
     at MongoDB.Driver.OperationExecutor.ExecuteReadOperationAsync[TResult](IReadBinding binding, IReadOperation`1 operation, CancellationToken cancellationToken)

How can I make this work using the MongoDb C# driver? This used to work fine in LinqProvider.V2

Hi @John_Staveley

Projection in LINQ3 is done on server side, while with LINQ2 it was done on client side, that’s why there is different behavior.
I was not able to reproduce this behavior with a data model I have assumed was used in this example.
If this behavior still occurs, the best way forward would be to create a self contained repro, and open a Jira ticket.