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

Unable to call ToString on Projections

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 2.9.3
    • 2.9.1
    • Linq
    • None
    • 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(), }}
      {{ });}}

      Attachments

        Activity

          People

            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            jake.stateresa@gmail.com Jake Sta Teresa
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: