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

How to create unique index using IMongoIndexManager.CreateOne with CreateIndexModel

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Command Operations
    • Labels:

      Description

      I'm not sure when this has changed, but since the

      IMongoIndexManager.CreateOne(IndexKeysDefinition<TDocument> keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken))

      overload has been marked as deprecated, I can't find a way to create a single unique index without using deprecated methods.

      In fact, the suggested one only accepts a CreateOneIndexOptions, which doesn't contain a property for setting the index as unique.

      IMongoIndexManager.CreateOne(CreateIndexModel<TDocument> model, CreateOneIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken));

      Plus, I see no mention of this change in the package release notes, and the documentation still uses the methods that are marked as deprecated. This is very confusing.

      Is there a reason why those methods were marked as obsolete? It seems that avoiding those only creates problems, because of missing properties and a more complex input type (CreateIndexModel instead of IndexKeysDefinition, but the first just wraps the second).

      Thanks.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rstam Robert Stam
              Reporter:
              matteocontrini Matteo Contrini
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: