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

Unable to call ToString on Projections

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.9.3
    • Affects Version/s: 2.9.1
    • Component/s: Linq
    • Labels:
      None
    • Minor Change

      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(), }}
      {{ });}}

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

              Created:
              Updated:
              Resolved: