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

Type casting in UpdateDefinition Linq query throws exception

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.2.4
    • Affects Version/s: 2.1
    • Component/s: Linq
    • None

      if you use casting in Linq expressions, driver can not determine serialization information. (Was working in 2.0.X)

      var updateDefinition = Builders<Message>.Update.Set(x => ((SmsMessage)x).TrackTryCount, smsMessage.TrackTryCount);
      
      _ctx.GetCollection<T>().UpdateOneAsync(x => x.Id.Equals(id), updateDefinition);
      
      System.InvalidOperationException: Unable to determine the serialization information for x => Convert(x).TrackTryCount.
      

            Assignee:
            craig.wilson@mongodb.com Craig Wilson
            Reporter:
            dato_dek David Dekanozishvili
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: