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

Cannot resolve method "UpdateOneAsync"

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None

    Description

      Summary

      I am trying to Update / Replace an document with the C# MongoDB.Driver.

       

      ``` csharp

      var Collection = DbContext.DbSet<MyEntity>();
      var filter = Builders<MyEntity>.Filter.Eq(x => x.Id, entity.Id);
      var update = Builders<MyEntity>.Update.Set(e => e.Name, entity.Name);
      await Collection.UpdateOneAsync(filter, update, cancellationToken);
      ```

       

      but whichever overload I am using, I get the error

       

      ```

      Cannot resolve method 'UpdateOneAsync(MongoDB.Driver.FilterDefinition<MyEntity>, MongoDB.Driver.UpdateDefinition<MyEntity>, System.Threading.CancellationToken)', candidates are: System.Threading.Tasks.Task<MongoDB.Driver.UpdateResult> UpdateOneAsync(MongoDB.Driver.FilterDefinition<MyEntity>, MongoDB.Driver.UpdateDefinition<MyEntity>, MongoDB.Driver.UpdateOptions, System.Threading.CancellationToken) (in interface IMongoCollection<MyEntity>) System.Threading.Tasks.Task<MongoDB.Driver.UpdateResult> UpdateOneAsync(MongoDB.Driver.IClientSessionHandle, MongoDB.Driver.FilterDefinition<MyEntity>, MongoDB.Driver.UpdateDefinition<MyEntity>, MongoDB.Driver.UpdateOptions, System.Threading.CancellationToken) (in interface IMongoCollection<MyEntity>) System.Threading.Tasks.Task<MongoDB.Driver.UpdateResult> UpdateOneAsync<MyEntity>(this MongoDB.Driver.IMongoCollection<MyEntity>, MongoDB.Driver.IClientSessionHandle, System.Linq.Expressions.Expression<System.Func<MyEntity,bool>>, MongoDB.Driver.UpdateDefinition<MyEntity>, MongoDB.Driver.UpdateOptions, System.Threading.CancellationToken) (in class IMongoCollectionExtensions) System.Threading.Tasks.Task<MongoDB.Driver.UpdateResult> UpdateOneAsync<MyEntity>(this MongoDB.Driver.IMongoCollection<MyEntity>, System.Linq.Expressions.Expression<System.Func<MyEntity,bool>>, MongoDB.Driver.UpdateDefinition<MyEntity>, MongoDB.Driver.UpdateOptions, System.Threading.CancellationToken) (in class IMongoCollectionExtensions)

      ```

       

      I guess this is a bug, but I am not sure if I am the one who does something wrong here.

      Other methods like "FindAsync", "InsertOneAsync", etc work as expected

      MongoDB.Driver: 2.18.0

      Attachments

        Activity

          People

            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            daniel@zookeeper.app Daniel Martin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: