[CSHARP-2399] Truncation resulted in data loss. Created: 26/Sep/18 Updated: 03/Jan/19 Resolved: 03/Jan/19 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Serialization |
| Affects Version/s: | 2.7.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Brecht Vanhaesebrouck | Assignee: | Robert Stam |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
.NET Core 2.1 |
||
| Description |
|
When running an aggregation through LINQ using IMongoQueryable I get this error when mapping to a decimal. My mapping looks like this:
Here's an example model which generates this error:
|
| Comments |
| Comment by Robert Stam [ 03/Jan/19 ] | |||||||||||||||||||||||||||||||
|
I've made another attempt to reproduce this, but the only data I have to go on is the example model from your description. I inserted that model into a collection using the MongoDB shell and am able to read it into an `SkuToOrder` instance without an exception being thrown. I can't actually run your LINQ query without some sample data. I'm going to close this as Can't Reproduce for now. If you can provide an executable reproduction I will be happy to look at this again. | |||||||||||||||||||||||||||||||
| Comment by Robert Stam [ 03/Jan/19 ] | |||||||||||||||||||||||||||||||
|
I will make another attempt to reproduce with the additional information you provided. It would be really helpful if you could provide a complete standalone console application that reproduces this, including sample data. Either the console application could create its own test data, or a MongoDB shell script could create the sample data. | |||||||||||||||||||||||||||||||
| Comment by Brecht Vanhaesebrouck [ 15/Oct/18 ] | |||||||||||||||||||||||||||||||
|
Here's the method I use to get the SKUs I need. I look for the SKUs that have been ordered in the past time (in the orders collection). Then I join the SKU collection to get the current stock. Your SkuToOrder class is correct.
| |||||||||||||||||||||||||||||||
| Comment by Robert Stam [ 12/Oct/18 ] | |||||||||||||||||||||||||||||||
|
I made a first attempt to reproduce using the following class definition for SkuToOrder
I then inserted your sample document using the MongoDB Shell and was able to read it without error using either a Find or a LINQ expression
So I'm assuming that in order to reproduce this I will need your actual LINQ expression. | |||||||||||||||||||||||||||||||
| Comment by Robert Stam [ 12/Oct/18 ] | |||||||||||||||||||||||||||||||
|
In order to reproduce this can you please supply the definition of your SkuToOrder C# class and the LINQ expression that throws an exception? | |||||||||||||||||||||||||||||||
| Comment by Brecht Vanhaesebrouck [ 09/Oct/18 ] | |||||||||||||||||||||||||||||||
|
I found a workaround for this issue: Add an aditional aggregation step where you multiply the values by 100 and divide by 100 again. | |||||||||||||||||||||||||||||||
| Comment by Brecht Vanhaesebrouck [ 26/Sep/18 ] | |||||||||||||||||||||||||||||||
|
Here's my stack trace:
|