[CSHARP-2757] Unable to call ToString on Projections Created: 26/Sep/19  Updated: 28/Oct/23  Resolved: 08/Oct/19

Status: Closed
Project: C# Driver
Component/s: Linq
Affects Version/s: 2.9.1
Fix Version/s: 2.9.3

Type: Bug Priority: Major - P3
Reporter: Jake Sta Teresa Assignee: Dmitry Lukyanov (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Minor Change

 Description   

I am trying to perform a query like the one below. Note that p.Date and p.Decimal are of type DateTime and decimal respectively. Calling ToString on the decimal value results in an exception whereas calling ToString on a DateTime value succeeds.

 

var query = repository
{{ .GetQueryable()}}
{{ .Where(p => p.Id == request.Id)}}
{{ .Select(p => new Projection}}
{{ { }}
{{ Date = p.Date, }}
{{ DateAsString = p.Date.ToString("%d/%m/%Y"),}}
{{ Decimal = p.Decimal,}}
{{ DecimalAsString = p.Decimal.ToString(), }}
{{ });}}



 Comments   
Comment by Githook User [ 08/Oct/19 ]

Author:

{'name': 'Dmitry Lukyanov', 'username': 'DmitryLukyanov', 'email': 'dmitry.lukyanov@mongodb.com'}

Message: CSHARP-2757: Unable to call ToString on Projections.
Branch: v2.9.x
https://github.com/mongodb/mongo-csharp-driver/commit/92ab15992a6393f92dbd7ce802b272f61e47caa7

Comment by Githook User [ 08/Oct/19 ]

Author:

{'username': 'DmitryLukyanov', 'email': 'dmitry.lukyanov@mongodb.com', 'name': 'Dmitry Lukyanov'}

Message: CSHARP-2757: Unable to call ToString on Projections.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/d99e2340ef2faa495357ea0e95afc52b57b059b1

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