[CSHARP-1604] Type casting in UpdateDefinition Linq query throws exception Created: 16/Mar/16  Updated: 18/May/16  Resolved: 17/Mar/16

Status: Closed
Project: C# Driver
Component/s: Linq
Affects Version/s: 2.1
Fix Version/s: 2.2.4

Type: Bug Priority: Major - P3
Reporter: David Dekanozishvili Assignee: Craig Wilson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CSHARP-1542 Using abstract type within Queryable ... Closed

 Description   

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.



 Comments   
Comment by Githook User [ 17/Mar/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1604: support downcasting.
Branch: v2.2.x
https://github.com/mongodb/mongo-csharp-driver/commit/98538f67a73c5e2454db87dadb904a8381564e21

Comment by Githook User [ 17/Mar/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1604: support downcasting.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/a06d0319514f213c5b0350d26c0bdd03cef1e6c7

Generated at Wed Feb 07 21:40:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.