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

DOCS: Case insensative string serialization in .NET driver

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Won't Fix
    • Affects Version/s: 1.8.2
    • Fix Version/s: None
    • Component/s: Serialization
    • Labels:
      None
    • Environment:
      C# Driver
    • Backwards Compatibility:
      Fully Compatible

      Description

      I would like an attribute which controls string serialization to / from Mongo at the C# layer. Something like

      [BsonStringOptions(UseLowerCase = true)]

      The motivation: Here's some feedback from a new app I'm working on in C#.

      We are coming from SQL Server where most string comparisons are case insensitive. Obviously MongoDB is case sensitive.

      There are plenty of fields we want to continue case insensitive comps on. For example, usernames, emails, urls, etc. We are fine to just store them all lowercase. But having the serialization engine help ensure this would help.

      It would be great if there was an attribute that would help with this (kind of like [BsonDateTimeOptions(Kind = DateTimeKind.Local)] for UTC vs Local time).

      So I'd like to offer a new feature idea:

      class Model {
      [BsonStringOptions(UseLowerCase = true)]
      public string Username

      {get; set;}

      }

      Where when this object is saved, it automatically converts to lowercase. I can do this in code, but it's a pain and potentially error prone.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: